How would I be able to get the innerHtml of the current aspx page in codebehind? I want to use the innerHTML and pass to a pdf converter function when the user clicks the pdf button, but i need the current page html as string.
我会回发并使用javascript提供当前的innerHTML
__doPostBack(**event target**, document.documentElement.innerHTML);
You can override Render
method of the page.
protected override void Render(HtmlTextWriter writer)
{
StringBuilder sb = new StringBuilder();
HtmlTextWriter tw = new HtmlTextWriter(new StringWriter(sb));
base.Render(tw);
string innerHtml = sb.ToString();
}
innerHtml will contain whole rendered html code of page. A little simplified version.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.