Using a sample extender
The following steps walk you through the process of using one of the sample ASP.NET AJAX
extenders on an ASP.NET web page. As you'll see, it takes less work to hook up the
extender than it does to create the page in the first place - and doesn't require
writing any code!
- If you haven't already done so, follow the steps to
setup your environment
Create a normal ASP.NET page to build on
- Using Visual Studio 2005 or Visual Web Developer, create a new web site from the
ASP.NET AJAX web site template by opening the "File" menu,
clicking "New", "Web Site...", and picking "ASP.NET AJAX Web Site" under "My Templates"
- Open Default.aspx by double-clicking it in the Solution Explorer
- Switch to design view by clicking the Design tab at the bottom of the window
- Add a Label (Label1) by dragging one over from the Toolbox
- Add a Button (Button1) by dragging one over from the Toolbox
- Create a Click handler for the Button by double-clicking it
- Default.aspx.cs will open automatically and the cursor will be in the Button1_Click
- Add the code
Label1.Text = "Button click was processed.";
- Run the page by pressing F5 (enable debugging if prompted) and verify that clicking
the Button in the browser changes the Label text
- Close the browser window
Add the AJAX Toolkit extender
- Add a ConfirmButtonExtender by dragging one over from the Toolbox
- Hook up the extender by clicking it, going to the Properties panel,
expanding the TargetControlID property drop-down, and choosing "Button1"
- Configure the extender by clicking the Button, expanding the ConfirmButtonExtender property,
and typing "Are you sure?" for the ConfirmText
- Run the page by pressing F5 and notice that clicking the button now brings up a
confirmation dialog that can be used to cancel the processing of the button press
That's all there is to it! You're now using an AJAX Control Toolkit extender!
Please refer to the individual sample pages (see the links on the left) for examples of
how to use the other samples.