Attack Work TMBeta
Productivity tools to accomplish work faster
 
Username Password
   
Password help
Create new account
Skip Navigation Links.

Asp.net - Render Control and Retrieve its HTML in Code

Steal This Site [Web Developer Blog]


The common way to utilize a control is to pass in properties and let the server render and display the resulting HTML. There are times when you'd want to retrieve and manipulate the rendered HTML in code before it's displayed to the user. This function allows you to pass in the control and it will return the rendered HTML as a string.

Code:
Function ControlRender(ByVal objControl As Control) As String
    Dim sb As New StringBuilder()
    Dim sw As New System.IO.StringWriter(sb)
    Dim htw As New HtmlTextWriter(sw)
    objControl.RenderControl(htw)
    Return sb.ToString()
End Function

Subscribe in a reader
Michael Khalili | Friday, October 31, 2008
Comments
All guest comments are moderated.
Be the first to comment on this post
Post your comment
Guest Name* !
Email Address* !(Not published)
Website !
Comment*
!
*Required fields


Terms of Service | Privacy Policy | Steal This Site
Attack Work and Voxback are trademarks of Hillside Holdings.