Home / AJAX

HOW TO Instantiate Controls with Web Server Controls

RSS
Modified on 2009/11/17 18:01 by Stephen Walther Categorized as Uncategorized
Image
When building an ASP.NET Web Forms application, you can add the controls from the ASP.NET Ajax Library to the Visual Studio Toolbox. That way, when you want to use an Ajax control, you simply can drag the control from the toolbox onto a Web Forms page.

Follow these steps to add the ASP.NET Ajax Library to the toolbox:

  1. In Visual Studio, create a new ASP.NET Web Site project or ASP.NET Web Application project.
  2. Open the Default.aspx page in the Visual Studio designer. (The Toolbox displays different items depending on the type of file that is open in the designer, so you must open a Web Forms page.)
  3. Right-click the Toolbox and then click Add Tab. Name the new tab ASP.NET Ajax Library (you are free to use any name of your choice).
  4. Right-click beneath the new ASP.NET Ajax Library tab and then click Choose Items… to open the Choose Toolbox Items dialog box.
  5. Click the Browse button and browse to the location where you downloaded the ASP.NET Ajax Library.
  6. In the Web Forms folder, select the AjaxControlToolkit.dll assembly and then click OK.
  7. Click OK to close the Choose Toolbox Items dialog and box and to update the Toolbox with the new controls. All the server controls that are included in the ASP.NET Ajax Library will appear in the Toolbox under the ASP.NET Ajax Library tab.

Adding a Control to a Web Forms Page from the Toolbox

To use the controls, you can drag them from the Toolbox to a page or you can use the Visual Studio Choose Extender wizard. For example, to use an ASP.NET Ajax Calendar control in a Web Forms page, follow these steps:

  1. Open a Web Forms page and switch to Design view.
  2. From the Standard tab of the Toolbox, drag a TextBox control to the page.
  3. From the ASP.NET Ajax Library tab of the Toolbox, drag a ToolkitScriptManager control onto the page. When you do, the System.Web.Ajax.dll and AjaxControlToolkit.dll assemblies are added to the Web application’s Bin folder automatically.
  4. Right-click the TextBox control and then click Add Extender. Selecting this option causes the Extender Wizard to appear.
  5. Select the CalendarExtender from the wizard and then click OK.

    Image


Image






  Name Size
- Calendar.png 35.15 KB
- ChooseExtender.png 43.69 KB
- Toolbox.png 33.85 KB