Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
How do I retrieve the html rendered for a web control in ASP .NET programmatically?
For instance something like:
dim controlHTML as string = myControl.GetHTML()
System.Text.StringBuilder sb = new System.Text.StringBuilder(); using (System.IO.StringWriter sw = new System.IO.StringWriter(sb)) using (System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(sw)) { mycontrol.RenderControl(hw); }
Add a comment
You have to actually call it's .RenderMethod, and pass in a HtmlTextWriter, and get the contents from that.
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.