Adding Client Capabilities to Server Controls Using the ASP.NET AJAX Control Toolkit - Part 2
Â
Adding Client Capabilities to Server Controls Using the ASP.NET AJAX Control Toolkit
Adding Design-Time Support to Your Extender Control
The introduction of the Extender Wizard in Visual Studio 2008 has enhanced the design-time experience with regard to working with extender controls, and this section explains how to add design-time features of your own to give your controls that professional feel that users have become accustomed to.
Default Design-Time Experience
TheImageRotatorDesigner
class shown in Listing 11.2 provides everything we need to get a basic design-time experience for our extender control. The ExenderControlBaseDesigner<t>
that it inherits from makes it possible for the properties of our extender control to show up in the Properties window while the design-time focus is on the image control we are extending. Figure 11.4 shows the RotationInterval
and ImageList
properties that appear in the Properties window while the image control has focus in the designer. This default feature addresses one issue, which is being able to work with the ImageRotator
properties in an integrated way, but still does not address the issue of data entry for the properties themselves and how that experience can be enhanced. (See Figure 11.4)
Adding Designers and Editors to Properties
In this section, we look at how to extend the design-time behavior of our ImageRotator ImageList
property. The ImageList
property that we worked with in Chapter 5 was rudimentary and prone to errors as a user entered in the values. In this version of the extender, we want to extend the functionality to support design-time editing and HTML source editing.
The road to these modifications requires a few steps as we add the functionality:
|
Add Attributes to the Class
Most users expect when adding multiple entries to a control to be able to add them in the body of the HTML element. This is the experience we have when adding web service references or script references to the Script Manager and one we want to have in our control.
The ParseChildren
attribute enables us to add multiple entries inside our ImageRotator
HTML tag and treat those entries as a single property assignment. By setting the ChildrenAsProperties
property to true and the DefaultProperty
to ImageList
, as in Listing 11.6, we are effectively telling the designer that we want to have all the items contained in the body of our ImageRotator
tag parsed and assigned to the ImageList
property. The HTML fragment in Listing 11.7 shows what this looks like when the HTML editor is opened and the ImageRotator
tag has entries.
Listing 11.6 ParseChildren
Attribute Assignment
NOTE: ASP.NET Server Control Designer References
The addition of designer features to your extenders requires some knowledge of how designers work. MSDN has some great information about this that covers adding design-time support to ASP.NET server controls.
[next]
URL: