?
Solved

Filter listbox contents client-side

Posted on 2012-08-13
4
Medium Priority
?
455 Views
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?
0
Comment
Question by:canuckconsulting
  • 2
  • 2
4 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 38288754
A link to the page would be helpful; or at the very least the HTML that the browser is seeing.

Cd&
0
 

Author Comment

by:canuckconsulting
ID: 38288797
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:DropDownList>
      </p>
      <p>
          <asp:ListBox ID="ListBox1" runat="server">
              <asp:ListItem Value="1,1">Book1</asp:ListItem>
              <asp:ListItem Value="1,2">Book 2</asp:ListItem>
          </asp:ListBox>

Open in new window

0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 1500 total points
ID: 38288966
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.

Cd&
0
 

Author Closing Comment

by:canuckconsulting
ID: 38293921
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:

http://jquerybyexample.blogspot.com/2012/05/how-to-move-items-between-listbox-using.html
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The first step to building an amazing About page is to figure out what you want the page to say about your company. You then must grab the attention of the reader, boast a bit, tell a story and let others brag about you. With a little bit of thought…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses
Course of the Month13 days, 11 hours left to enroll

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