The server extender's definition looks like the following
skeleton. Note the various uses of attributes.
public class ButtonEnabledExtender: ExtenderControlBase
In the AJAX Control Toolkit API there are two main base
classes for developing custom controls: ExtenderControlBase and
ScriptControlBase. The ExtenderControlBase class is used in this example
because we are building an extender. For all extenders, these controls have a TargetControlID
property; this property is linking the extender to the server control (and
eventually underlying HTML element when it is rendered) that the extender control
what type the controls can be.
Each server component has a server class (.cs or .vb) file
files are marked as embedded resources in Visual Studio to the client class
that it represents. These files are later extracted using the framework
components; no work is necessary for this on your part.
Moving along, to how easy the describing process is, the
following properties and event handlers are illustrated below. I will start by
illustrating the properties.
public bool IsEnabledInitially
return base.GetPropertyValue < bool > ("IsEnabledInitially", true);
base.SetPropertyValue < bool > ("IsEnabledInitially", value);
public string ReceiverControlID
return base.GetPropertyValue < string > ("ReceiverControlID", null);
base.SetPropertyValue < string > ("ReceiverControlID", value);
The ExtenderControlProperty attribute maps the server
control properties to a property in the client component; otherwise, a
client-side error will be thrown if there is an invalid mapping. The
ClientPropertyName attribute specified the name of the property on the client
side if different than the property on the server-side. At runtime, the server
will push down the initial values it defines to the client component.
One other important attribute to note is if you have any
properties that reference another control (for both extenders and controls),
the IDReferenceProperty allows for proper retrieval of the ClientID at
For this extender, only one event is needed.
public string OnClientEnabledStatusChanged
return base.GetPropertyValue < string > ("OnClientEnabledStatusChanged",
base.SetPropertyValue < string > ("OnClientEnabledStatusChanged", value);
This event allows an ASPX page to provide the name of a
raised on the client side (more on this soon). At runtime, the name of this
the event is fired from the client component.
One other note: The GetPropertyValue and SetPropertyValue
generic methods read/write data to/from ViewState; they are simply helper
methods for this process. That is all from the server component. That is all
the code that is needed at the moment to setup our ButtonEnabledExtender
control. It is that simple; the only item remaining is the client component.