Listboxes and JavaScript

Results 1 to 2 of 2

Thread: Listboxes and JavaScript

  1. #1
    Join Date
    Dec 1969

    Default Listboxes and JavaScript

    I have been struggling with this issue for quite some time now and I <BR>cannot seem to find the answer. My quesiton is this: I have an <BR>asp:listbox control that Is full of info from a database. I have <BR>another asp:listbox that is empty. In order to speed the submission <BR>process of the form, I have included Javascript on the page that allows <BR>visitors to add Items to the empty listbox by double clicking on an item <BR>in the full listbox. - This works fine and dandy. However, when I try <BR>to read the items added to the empty box with my ASP.NET code, it looks <BR>as though the box is empty. <BR><BR>I have been getting around this by moving items to a hidden text box and <BR>using tags to identify each item, then when I try to recover the <BR>information from the listbox, I instead read from the hidden text box. <BR>However this is pain in the butt and leaves more room for errors. I <BR>would like to avoid this step if possible and just read from the listbox <BR>directly. Does ASP.NET allow me to do this since I am using Javascript <BR>to add items to the box?? If so, how can I do this? <BR><BR>Thanks for your time. <BR>

  2. #2
    Join Date
    Dec 1969

    Default I *think* the solution... to *NOT* use a RUNAT=SERVER listbox!<BR><BR>When you do that, ASP.NET remembers the values in the listbox on the server and doesn&#039;t bother looking for them coming from the client.<BR><BR>I think an ordinary &#060;SELECT&#062; should do what you want.<BR><BR>HOWEVER...<BR><BR>The other possible problem: Are you using JS code to set the .selected property on *ALL* the items in the added-to listbox???<BR><BR>If you aren&#039;t, then submitting the &#060;FORM&#062; will *NOT* allow the processing page to see that you&#039;ve added anything! This is because the browser *only* sends selected items from a &#060;SELECT&#062; back to the server. And, under it all, an asp:listbox is implemented via a simple &#060;SELECT&#062;, isn&#039;t it?<BR><BR>Do you know how to use JS to select all the items in a &#060;SELECT&#062;?<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts