Few questions on custom controls

  • Thread starter Thread starter rn5a
  • Start date Start date
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?
 
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
 
Back
Top