Get inner html of an HTML element from codebehind file

  • Thread starter Thread starter eggie5
  • Start date Start date
E

eggie5

So, I'm in my code behind file (Page_Load to be exact) and I need to
get the HTML generated by my repeater and save it to a string? How can
I do this, is the HTML even generated at Page_Load time, or do I need
to wait? If so, just tell me to what event, and then how I can get that
HTML to a string in my code behind file.

Thanks,
Alex
 
I figured it out. I just added a flag to my method that builds the
repeater and added this code to the bottom of that method:

if (render)
{
StringBuilder sb= new StringBuilder();

StringWriter sw= new StringWriter(sb);

HtmlTextWriter hw= new
HtmlTextWriter(sw);
RepeaterPapers.RenderControl(hw);

return sb.ToString();

}

So if render is true, it will return immediately with the html of the
repeater!
 
Please Help me out !! Can I use this to get HTML code of a table
created dynamically on the page ???
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top