Control Extenders in ASP.NET AJAX


ScottGu has written a wonderful article here on the functionality of extender controls which are shipped with the ASP.NET AJAX framework in VS 2008.  Also you can build a new extender control from scratch here. So the foremost question is why do you go for an extendercontrol any way? First and foremost, an extender control is a server control itself. It represents a logical behavior that can be attached to one or more control types to extend their base capabilities. Suppose lets assume you have created a textbox and the user has to enter only values of type “int” . How can block the content the user to enter only values of type “int”?

               Using Control Extenders you can achieve this functionality both in VS 2005 and VS 2008. If you are using VS 2005 you need to install the AJAX Control Toolkit available here. If you are using VS 2008 Orcas the Control tool kit is already available. No seperate installation  is required. In this article I will give a small sample to demonstrate the capabilities of  FilteredTextbox Extender control.

1. Open Visual Studio 2008.

2. File->New->Website. Select a location and language for the website.

3. Go to design view, drag a textbox control and drop it on the design surface.

4. If you see the textbox control in the design view, you can see a “>” symbol hovering about the textbox

 5. If you click that “>” symbol it will pop up the following screen.

24.jpg

6.Click Add extender, and select FilteredTextBox Control in the below screen.

3.jpg

7. Once you select the appropriate extender control  the intellisense will automatically generate the required markup HTML in the source file. In the souce code select the FilerType property of the FilteredTextbox control to “Numbers” as shown.

4.jpg

8. Save the file and Hit F5.

9. Now observe that the textbox will not allow the user to type anything which is non numeric.

Advertisements
This entry was posted in ASP.NET. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s