Render vs RenderContents

A

Alex Nitulescu

Hi.

What's the difference between the Render method (overridden when creating
custom controls) and the RenderContents method.... (overridden when creating
custom controls) ?

From MSDN:

Render - Sends server control content to a provided HtmlTextWriter object,
which writes the content to be rendered on the client.
Overridable Protected Sub Render( ByVal writer As HtmlTextWriter )

RenderContents - Renders the contents of the control into the specified
writer. This method is used primarily by control developers.
Overridable Protected Sub RenderContents( ByVal writer As HtmlTextWriter )

So.... to me, it's not any clearer than before reading these "helpful"
lines. To me, they are just the same.

Thank you,
Alex.
 
M

MasterGaurav

The WebControl breaks down the "Render" method of Control method into
three parts:

1. StartingTag: RenderBeginTag
2. Content within tag: RenderControl
3. End of Tag: RenderEndTag

If you want to provide full functionality on your own, override the
Render Method.

However, if you wish to use RenderBeginTag and RenderEndTag
functionality as provided in WebControl and wish to provide only the
inner content, override RenderControl.



--
Cheers,
Gaurav Vaish
http://www.mastergaurav.org
http://mastergaurav.blogspot.com
--------------------------------
 
Joined
Sep 23, 2008
Messages
3
Reaction score
0
Render Vs RenderContent method

When writing a custom Web control that derives from a standard ASP.net web control it is indeed confusing what method to override in order to have the new control OK.
From my experience it seems that rendercontent renders within the opening and closing tag of the original control (if this is allowed by the derived from control), whereas render renders the output that will be send to the browser.
 

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,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top