Render vs RenderControl

  • Thread starter Thread starter George Ter-Saakov
  • Start date Start date
G

George Ter-Saakov

I am trying to wrap PlaceHolder so it will output prefix/suffix (like <div>,
</div>) before render the actual control.

So i created
public class clsSection : PlaceHolder

protected override void Render(HtmlTextWriter writer)

{

writer.Write(_sPrefix);

base.RenderControl(writer);

writer.Write(_sSuffix);

}

But Render is never called. I tried to override RenderControl but it never
called either.

1. What do i do to implement that feature.

2. What is the difference between Render and RenderControl?

Thanks.

George.
 
I figured why Render was never called. ( I never added the control to the
Page's controls collection).

The question what is the difference between Render and RenderControl
remains.

Thanks.
George.
 
Hi George,

Based on my research and experience, I would like to share the following
information with you.

The base class of a Web control has several Render methods available. All
of these use the HTMLTextWriter class to render content.

The Render method enables the controller to render itself by writing HTML
output to the response stream. This passes a reference to the
HTMLTextWriter object, which can write directly to the response stream.
This method should be used when you derive directly from control.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemwebuicontrolclassrendertopic.asp

The RenderControl method is used by the page to render each individual
control. It allows the consumer of your class to render it, and you can use
it to render the child controls if you're using a composite control. Also,
one thing to note is that this will not be invoked if the visibility
property on the control is set to false.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemwebuicontrolclassrendercontroltopic.asp

Does it answer your question? If I have misunderstood your concern, please
feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top