Choosing the Base Class for Your Control


These guidelines will help you determine the base class from which to derive your control:

  • Derive from System.Web.UI.Control if your control renders nonvisual elements or renders to a non-HTML client. The <meta> and <xml> tags are examples of nonvisual rendering.

  • Derive from System.Web.UI.WebControls.WebControl if you want to render HTML that generates a visual interface on the client.

  • Derive from an existing control ”such as Label , Button , and TextBox ” when you want to extend or modify the functionality of that control. You can derive from any control in the System.Web.UI.WebControls namespace or from a custom control. However, do not derive from controls in the System.Web.UI.HtmlControls namespace. Controls that derive directly or indirectly from HtmlControl are not allowed in the Visual Studio .NET designer because they break the HTML control model. HTML controls are intended to appear without a tag prefix in declarative page syntax (such as <Button runat ="server" /> ). However, all custom controls ”including those deriving from HtmlControl or its descendants ”require a tag prefix when used declaratively on a page.

The object models for the Control and WebControl base classes are described in Appendix B, "Object Model for Key Classes."



Developing Microsoft ASP. NET Server Controls and Components
Developing Microsoft ASP.NET Server Controls and Components (Pro-Developer)
ISBN: 0735615829
EAN: 2147483647
Year: 2005
Pages: 183

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net