Get inner html of an HTML element from codebehind file

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
 
E

eggie5

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!
 
A

Aur_Ros

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top