Render vs RenderControl

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.
 
G

George Ter-Saakov

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.
 
J

Jacob Yang [MSFT]

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.
 
Joined
Oct 23, 2006
Messages
2
Reaction score
0
Hello Jacob,

I have a similar issue. I have to create certain LinkButtons dynamically and place them in a particular locatin in ASPX page.

Is it possible to create the controls dynamically in Page load and place them on a specific location in the aspx page??

I tried with renderControl and fed up with exceptions.

Can u provide an exmaple?

Thanks,
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top