What's the difference between Render() and RenderControl() methods in the Control class. When should I call which, and why should I override Render and not RenderControl?
Who can help me on this one. Google and MSDN are not of any help.
Render is a protected method, meaning that only derived Classes can access it. It is called within the Event Lifecycle, and shouldn't be explicitly called in your code.
RenderControl is a public method that allows you to call the Render method when you want. You would use it in, say, a Custom Control where you store Controls in the ControlsCollection but want to Render them in their own cell in a table. For example:
dekale
Member
235 Points
47 Posts
What's the difference between Render() and RenderControl()
Aug 08, 2005 10:40 PM|LINK
Who can help me on this one. Google and MSDN are not of any help.
stevenbey
All-Star
16526 Points
3378 Posts
Re: What's the difference between Render() and RenderControl()
Aug 09, 2005 08:22 AM|LINK
RenderControl is a public method that allows you to call the Render method when you want. You would use it in, say, a Custom Control where you store Controls in the ControlsCollection but want to Render them in their own cell in a table. For example:
writer.Write("<table><tr>"):
foreach(Control ctl in Controls)
{
writer.Write("<td>")
ctl.RenderControl(writer);
writer.Write("</td>");
}
writer.Write("</tr></table>");
You should always override Render, and not RenderControl, as it is called in the Event Lifecycle (as I have already said).
http://stevenbey.com
Recursion: see Recursion
dekale
Member
235 Points
47 Posts
Re: What's the difference between Render() and RenderControl()
Aug 09, 2005 01:00 PM|LINK
Thanx