Server Control Overview


An ASP.NET server control is a component that executes program logic on the server, provides a programmable object model, and renders markup text (such as HTML, XML, and WML) to a Web browser client or other viewing device. A server control is a fundamental building block of an ASP.NET Web application. Although a significant amount of plumbing is needed to enable a class to interact with the ASP.NET page framework and to participate in an HTTP request/response scenario, ASP.NET frees you from low-level details by providing a base class ( System.Web.UI.Control ) that implements the necessary plumbing. To author a server control, you must define a class that directly or indirectly derives from System.Web.UI.Control . All ASP.NET controls that ship with the .NET Framework SDK derive from Control or from one of its derived classes.

Figure 5-1 shows the hierarchy of the base classes for server controls. The full class hierarchy containing all the server controls in ASP.NET is shown in Chapter 2, "Page Programming Model."

Figure 5-1. Hierarchy of the base classes for server controls

graphics/f05hn01.jpg

The Control class provides the basic functionality for participating in the page framework. In particular, it provides the functionality that allows a server control to be placed within the control tree that represents an .aspx page. The Control class also implements the System.ComponentModel.IComponent interface, which makes it a designable component. A designable component can be added to the toolbox of a visual designer, can be dragged onto a design surface, can display its properties in a property browser, and can provide other kinds of design-time support.

The WebControl class adds functionality to the base Control class for rendering HTML content. WebControl provides support for styles through properties such as Font , Height , Width , BackColor , and ForeColor . Later in this chapter, in the "Choosing the Base Class for Your Control" section, we will provide scenario-based guidelines to help you determine the base control class from which you should derive your control.



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