Results 1 to 3 of 3

Thread: html code of web controls

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2003
    Posts
    16

    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?

  2. #2
    Addicted Member
    Join Date
    Sep 2003
    Posts
    227
    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

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2003
    Posts
    16
    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
  •  



Click Here to Expand Forum to Full Width