Few questions on custom controls

R

rn5a

While creating a custom control, what is the difference between

Public Class MyCls : Inherits Control

&

Public Class MyCls : Inherits WebControl

Also when should the sub Render be used & when should the sub
RenderContents be used?

Also does it make any sense in using the sub AddAttributesToRender if
the class is being inherited from the WebControl class since the
WebControl class will always render a <span> element?
 
S

Steve C. Orr [MVP, MCSD]

You should inherit from Control when your custom control doesn't have much
of any UI to display.
Inheriting from WebControl gets you everything that Control supplies plus
some extra UI goodies, such as CSS support and some other fancy UI goodies.

As for which rendering method you should use I suggest you read about
composition vs. rendering:
http://msdn.microsoft.com/library/d.../cpguide/html/cpconcompositionvsrendering.asp

http://SteveOrr.net/articles/BarGraphs.aspx

And for more info about your final question I suggest you read this link:
http://geekswithblogs.net/mcastro/archive/2006/01/19/66393.aspx
 

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

Similar Threads


Top