15.02.2015 Views

C# 4 and .NET 4

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

1232 ❘ ChaPTer 41 Asp.net feAtures<br />

Using extender Controls<br />

The core ASP.<strong>NET</strong> AJAX download includes a class called ExtenderControl. The purpose of this control<br />

is to enable you to extend (that is, add functionality to) other ASP.<strong>NET</strong> server controls. This is used<br />

extensively in the AJAX Control Toolkit to great effect, <strong>and</strong> you can use the ASP.<strong>NET</strong> AJAX Server Control<br />

Extender project template to create your own extended controls. ExtenderControl controls all work in a<br />

similar way — you place them on a page, associate them with target controls, <strong>and</strong> add further configuration.<br />

The extender then emits client-side code to add functionality.<br />

To see this in action in a simple example, create a new empty web site called PCSExtenderDemo in the<br />

C:\ProCSharp\Chapter41 directory, add the AJAX Control Toolkit assembly to the bin directory of<br />

the web site, <strong>and</strong> then add the following code to a new web form called Default.aspx:<br />

<br />

<br />

<br />

<br />

<br />

Color Selector<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

My favorite color is:<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

code snippet PCSExtenderDemo/Default.aspx<br />

www.it-ebooks.info

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!