|
-
Nov 18th, 2003, 02:43 AM
#1
Thread Starter
Junior Member
html code of web controls
is there any way i can get the corresponding HTML code of a web control?
For example, i have an asp.net table with w/ one row and one cell with the text "sample". I want to get this string:
"<table><tr><td>sample</td></tr></table>"
Is this possible?
-
Nov 18th, 2003, 03:52 PM
#2
Addicted Member
i guess you could put the web control on your page, press the run button,then right click on the webbrowser,nd in the context menu click view source, you can find the html code for you control there
-
Nov 18th, 2003, 11:31 PM
#3
Thread Starter
Junior Member
Yeah, but I need to retrieve the html code from the program. Anyway, I have already solved it. Here's the code I used:
//returns the html code of the specified web control
public static string RenderHTML(System.Web.UI.WebControls.WebControl control)
{
StringBuilder SB = new StringBuilder();
System.IO.StringWriter SW = new System.IO.StringWriter(SB);
System.Web.UI.Html32TextWriter htmlTW = new Html32TextWriter(SW);
control.RenderControl(htmlTW);
string html = SB.ToString();
return html;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|