uid | title | author | description | ms.author | ms.date | ms.assetid | msc.legacyurl | msc.type |
---|---|---|---|---|---|---|---|---|
web-forms/overview/ajax-control-toolkit/cascadingdropdown/presetting-list-entries-with-cascadingdropdown-vb |
Presetting List Entries with CascadingDropDown (VB) | Microsoft Docs |
wenz |
The CascadingDropDown control in the AJAX Control Toolkit extends a DropDownList control so that changes for one DropDownList loads associated values in anoth... (VB) |
riande |
06/02/2008 |
ec61ced7-bbca-4bdd-aa3b-80878f295181 |
/web-forms/overview/ajax-control-toolkit/cascadingdropdown/presetting-list-entries-with-cascadingdropdown-vb |
authoredcontent |
The CascadingDropDown control in the AJAX Control Toolkit extends a DropDownList control so that changes in one DropDownList loads associated values in another DropDownList. With a little bit of code it is possible that a list element is preselected once the data has been dynamically loaded.
The CascadingDropDown control in the AJAX Control Toolkit extends a DropDownList control so that changes in one DropDownList loads associated values in another DropDownList. (For instance, one list provides a list of US states, and the next list is then filled with major cities in that state.) With a little bit of code it is possible that a list element is preselected once the data has been dynamically loaded.
In order to activate the functionality of ASP.NET AJAX and the Control Toolkit, the ScriptManager
control must be put anywhere on the page (but within the <form>
element):
[!code-aspxMain]
Then, a DropDownList control is required:
[!code-aspxMain]
For this list, a CascadingDropDown extender is added, providing web service URL and method information:
[!code-aspxMain]
The CascadingDropDown extender then asynchronously calls a web service with the following method signature:
[!code-vbMain]
The method returns an array of type CascadingDropDown value. The type's constructor expects first the list entry's caption and then the value (HTML value
attribute). If the third argument is set to true, the list element is automatically selected in the browser.
[!code-aspxMain]
Loading the page in the browser will fill the dropdown list with three vendors, the second one being preselected.
The list is filled and preselected automatically (Click to view full-size image)