O'Reilly logo

ASP.NET jQuery Cookbook by Sonal Aneel Allana

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Populating ASP.NET DropDownList using AJAX

In this recipe, we will create a cascading dropdown. We will populate the values in the second DropDownList based on the selected value in the first DropDownList. We will make an AJAX call to a page method to retrieve the contents of the second DropDownList.

Getting ready

  1. Add a new web form Recipe5.aspx to the current project.
  2. Add the following DropDownList to the form:
    <asp:DropDownList ID="ddlUserID" runat="server">
    <asp:ListItem Text="Please select" Value="[-]"></asp:ListItem>
    <asp:ListItem Text="UserID1" Value="UserID1"></asp:ListItem>
    <asp:ListItem Text="UserID2" Value="UserID2"></asp:ListItem>
    <asp:ListItem Text="UserID3" Value="UserID3"></asp:ListItem>
    </asp:DropDownList>
    
  3. Add another empty DropDownList ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required