CascadingDropDown Demonstration
Make
Model
Color

[No response provided yet]
CascadingDropDown Description

CascadingDropDown is an ASP.NET AJAX extender that can be attached to an ASP.NET DropDownList control to get automatic population of a set of DropDownList controls. Each time the selection of one the DropDownList controls changes, the CascadingDropDown makes a call to a specified web service to retrieve the list of values for the next DropDownList in the set. CascadingDropDown enables a common scenario in which the contents of one list depends on the selection of another list and does so without having to embed the entire data set in the page or transfer it to the client at all. All the logic about the contents of the set of DropDownList controls lives on the server in a web service. This web service can use any suitable method for storing and looking up the relevant data. The sample web service used here reads the data set from a simple hierarchical XML data file. The sample data file shows that the DropDownList items can have distinct names and value (values are optional in the sample).

CascadingDropDown Properties

The control above is initialized with this code. The italic properties are optional:

<ajaxToolkit:CascadingDropDown ID="CDD1" runat="server"
    TargetControlID="DropDownList2"
    Category="Model"
    PromptText="Please select a model"
    LoadingText="[Loading models...]"
    ServicePath="CarsService.asmx"
    ServiceMethod="GetDropDownContents"
    ParentControlID="DropDownList1"
    SelectedValue="SomeValue" />
  • TargetControlID - The ID of the DropDownList to modify
  • Category - The name of the category this DropDownList represents
  • PromptText - Optional text with which to prompt the user when this DropDownList is empty
  • LoadingText - Optional text to display while the data for the DropDownList is being loaded
  • ServicePath - Path to a web service that returns the data used to populate the DropDownList. This property should be left null if ServiceMethod refers to a page method.
  • ServiceMethod - Web service method that returns the data used to populate the DropDownList. The signature of this method must match the following:
    [WebMethod]
    public CascadingDropDownNameValue[] GetDropDownContents(
           string knownCategoryValues, string category){...}
    Note you can replace "GetDropDownContents" with a naming of your choice, but the return type and parameter name and type must exactly match, including case.
  • ParentControlID - Optional ID of the parent DropDownList that controls the contents of this DropDownList
  • SelectedValue - Optional value to select by default. This needs to exactly match the string representation of a value in the drop down list.
Copyright © 2006 Microsoft Corporation. All Rights Reserved.