Filter listbox contents client-side

Posted on 2012-08-13
Last Modified: 2012-08-14
I have a .Net web application created with c# using Visual Studio 2010.

On a web page a have a DropDownList containing containing a list of publishers.  Below that I have ListBox displaying books for the selected publisher.  I would like the list to update when the users selects a publisher in the DropDownList.  I can do this server-side but how can I do it client-side for quicker performance?
Question by:canuckconsulting
    LVL 53

    Expert Comment

    A link to the page would be helpful; or at the very least the HTML that the browser is seeing.


    Author Comment

    It is something I am developing.  Just an asp:DropDownList  followed by an asp:ListBox.  If it helps it will look like:

              <asp:DropDownList ID="DropDownList1" runat="server">
                  <asp:ListItem Value="1">Publisher 1</asp:ListItem>
                  <asp:ListItem Value="2">Publisher 2</asp:ListItem>
              <asp:ListBox ID="ListBox1" runat="server">
                  <asp:ListItem Value="1,1">Book1</asp:ListItem>
                  <asp:ListItem Value="1,2">Book 2</asp:ListItem>

    Open in new window

    LVL 53

    Accepted Solution

    Well you posted the asp code instead of the HTML, but in any case.  What you can do is generate each list into div that has a css property of display:hidden.  Then on the change event for the select.  Just swap in the innerHTML of the appropriate hidden element to the element holding the displayed list.


    Author Closing Comment

    Thanks for the help which worked fine.

    In the end I used jquery and something similar to this do to the next requirement I had:

    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
    This video teaches users how to migrate an existing Wordpress website to a new domain.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now