I was working on a project where I needed to get the current page's HTML. I searched all over the Internet and could not find anything. Then I thought about the Page's built-in methods...
Render! Here's how you get it:
1sw = new StringWriter();
2htmltw = new HtmlTextWriter(sw);
3base.Render(htmltw);
4StringBuilder html = sw.GetStringBuilder();
And be sure to drop this code in the "OnPreRenderComplete" method (you'll need to create an override in your code-behind).
Well that was easy enough, huh?
Comments
|
On
1/8/2010
payal
said:
i am also getting "A page can have only one server-side Form tag." error plz help
On
1/8/2010
Brian Pautsch
said:
I was getting that error at first too…but it went away and I can’t remember what I did to fix it.
On
1/8/2010
Dave Cooper
said:
Nice, looking for something like this, but there are a few issues.
On
2/26/2007
Todor
said:
Did you ever remember how to address the "A page can have only one server-side Form tag." issue after overriding OnPreRenderComplete?
|
Leave a Comment