Performance wise whats better?

S

Showjumper

With respect to performance, whats better - using the the utility methods of
HtmlTextWriter to render the control or to use
Dim inputa As New TextBox
Dim butt As New Button
inputa.RenderControl(wr)
butt.RenderControl(wr)


As i understand it direct render via the utility methods is better because
there is not extra overhead but does it really make that much of a
difference?

Thanks Ashok
 
S

Steve C. Orr [MVP, MCSD]

The HTMLTextWriter methods will usually offer slightly better performance.
However, creating web controls manually (as in your example) is usually more
efficient with your development time, and it's also less bug-prone because
the standard web controls have already been through rigorous testing.
 
S

Showjumper

Up till know i have made controls by making composite controls using
controls.add(thenamegoeshere) and calling renderchildren. Is creating them
manually in the render routine essentially the same as using the
controls.add method in a composite control and calling renderchildren and
does it also incur the hit compsotie controls incur?

Thanks Ashok...
 
S

Steve C. Orr [MVP, MCSD]

Either way you're creating the same number of controls so there should be no
significant performance difference.
 
R

recoil

An alternative that may result in less code is doing something like
using a LiteralControl or a HtmlGenericControl("div") and adding all of
your controls to this container. Then call
ThisContainer.RenderControl(mywriter);

I usually use a WholeContainer which is a div that I have specially
styled and I add all my child control's for a web control to this.
 

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

Forum statistics

Threads
473,731
Messages
2,569,432
Members
44,835
Latest member
KetoRushACVBuy

Latest Threads

Top