In ASP.NET 1.1, we would have had to add a protected
member in the code behind page, like in the following code, but this additional typing is no
longer required in the ASP.NET 2.0 and later code-behind model:
protected ControlsBook2Web.Ch02.TableUserControl TableUserControl1;
After this chapter, we do not touch on building user controls, as this book focuses on building
custom server controls. For more information on building ASP.NET user controls, please refer
to the ASP.NET documentation.
Building a Custom Control
We now turn our attention to creating custom server controls. The first decision that we must
make when building a custom server control is what base class to inherit from. In the next
section, we cover the generic base classes that are available to inherit from in addition to some
decision-making guidelines on which base class to use.
Which Base Class?
The discussion of the control hierarchy in Chapter 1covered the various families of controls in
the three main namespaces: System.Web.UI, System.Web.UI.WebControls, and System.Web.UI.
HtmlControls. You have the option to inherit from any of the controls in these namespaces.
For those who prefer to start with a blank slate, which is the approach we take in this
section, three control classes stand out as a potential starting point:
??? System.
Pages:
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124