Accessing List Items that were added to a list box via JavaScript



  • 1. How to access session information during StateServer mode in ASP .Net
    Thanks in advance I want sessions information for the asp .net application ( mainly SessionId). I am using Oracle as back end. I have sessionid using Session.SessionID in asp .net. I am gettin session id value in program like "piaelorpl0xqn0vtjlawi2vq". I want complete information for this ID like start time, last access time etc. I can get all of this information when sessionstate mode is SQLServer but i dont know how to get when mode is StateServer. I have set session time out 10 minutes in web.config and sessionstate mode=stateserver. Now i want find which sessions are live at the time of Login in my application.
  • 2. ico editor in VS.NET
    I was just screwing around and double clicked on an ico file and it opened in Visual Studio and can be edited. I can't believe I haven't heard about this feature of VS.NET before. Has this ico editor always been included in VS.NET? Any recommendations for or against using it? Thanks.
  • 3. page_load fires two times
    Hello, I've an ASP.NET-page in which there are some fields with data from a database and an OK-button. When the page loads (so this code is in the Page_Load-part) some data is send to the database (with MySql 'INSERT'-statement). But when I click the OK-button I see the same data is being resend to the database. So Page_Load is fired again while it shouldn't! Any-one knows how this could be happening? Thanks in advance for any help! Arjen

Accessing List Items that were added to a list box via JavaScript

Postby Scott324 » Sat, 29 Oct 2005 01:24:36 GMT

Need some help guys:

I have two list boxes that I am moving LI's back and forth.  I
initially fill listboxA with a datareader.   I move any/all/some/etc
items from listboxA to listboxB.  I then cannot loop through items in
listboxB on the server.  It acts as if the items were never really
added even though I can access them through JavaScript.

Both the listboxes are server controls.  I am not reinitializing the
listboxes when trying to loop through.

Is there a way via Javascript to make the server think the li's have
been moved.

One other side note.  Serverside the count on listboxA never changes
even if I move all items to listboxB.

If there is no way to do it, can someone give a good thorough
explanation of Why not!!!


Re: Accessing List Items that were added to a list box via JavaScript

Postby Jason Kester » Sat, 29 Oct 2005 01:39:25 GMT

That's not how SELECT boxes work in CGI.  The browser will submit a
comma separated list of selected values.  So if your user (or
javascript) were to manually select all the items in ListBoxB before
submitting the form, then they would be available to you in
Request.Form["ListBoxB"], and possibly even the server representation
of listboxB.

If you want to keep a list of what's in box B, you'll need to do it by
hand.  Check out any battling listbox example out there, and that's how
it is always done.  You'll maintain a comma separated list of values in
a hidden input, rebuilding that list in the same piece of script that
you use to move the Option items from box to box.

You should always try to learn what ASP.NET is doing for you behind the
scenes, so that you don't come up against frustrating situations like
this in the future.  ASP.NET gives you the illusion that ListBoxes stay
alive between trips to the server, but in reality it is only
reconstituting those boxes from information that it stored in the
VIEWSTATE the last time it was at the server.  This works great in the
simple case, where you're just selecting an item that's already in the
list.  But as you've learned, there's no way to tell the VIEWSTATE
about changes to the Options colection.

Good luck!

Jason Kester
Expat Software Consulting Services

Get your own Travel Blog, with itinerary maps and photos!

Re: Accessing List Items that were added to a list box via JavaScript

Postby Scott324 » Sat, 29 Oct 2005 02:35:11 GMT


Thanks for the reply.  Just to clear things up I am not concerned so
much with the actual select process.  Just when the Javascript moves a
LI from A to B the server doesn't recognize the move.  You explanation
cleared it up though, the viewstate is not reflecting the changes made
by javascript.  Thanks,  any way to update the viewstate?

Re: Accessing List Items that were added to a list box via JavaScript

Postby Jason Kester » Sat, 29 Oct 2005 06:17:00 GMT

Not really.  Unless you want to decrypt it, modify it and re-encrypt it
all from Javascript.  It's probably technically doable, but I doubt
anybody has tried.


Similar Threads:

1.JavaScript: html list items within list items?


 I've seen how to implement a JavaScript to change the CSS class of every other 
list item in an unordered list, but, being new to JavaScript, I'm trying to 
puzzle out how I can exclude list items within a list item of the targeted 
unordered list from being included in the function. In CSS, I can refer to a 
descendent li by coding: li li. 

 Perhaps there is a JS method to look at the parent element of the targeted 
element ... I have to figure out how to keep these nested list items from being 
included in the function. The function uses the modulus to determine whether or 
not the element is even or odd-numbered, then it changes the CSS class if it's 



2.List Box Crash When Several Items Added

I have looked everywhere I can for a solution to this problem but
nothing so far has worked.

I have two list boxes in my form. The first one (selAvailable) is
populated from an access database. The second (selSelected) is
populated by selecting items in selAvailable and clicking the add
button. In some situations there can be hundreds or thousands of items
in the selAvailable list box. If a user selects a few hundred or
clicks the Add All button the selSelected list box will begin to
populate until the whole page freezes then crashes.

I tried making the list box selSelected invisible before added items
to it but that did not help.

I know it seems that no user would ever want to have a list box with
so many items but in the context of my webpage it is needed.

Below is the Add All code that adds all of the items from the
selAvailable list box to the selSelected list box. I greatly
appreciate anyones help, thank you very much in advance.


function AllAdd()
var i
var count
var selectedText
var selectedValue
var selAvailableLength = frmSelect.selAvailable.length
var selSelectedLength = frmSelect.selSelected.length
var newoption

var count = selSelectedLength + 0;

for (i = 0; i < selAvailableLength; i++)
	selectedText = frmSelect.selAvailable.options[i].text;
	selectedValue = frmSelect.selAvailable.options[i].value;
	newoption = new Option(selectedText, selectedValue, false, false);
	frmSelect.selSelected.options[count] = newoption;
	count = count + 1;
	frmSelect.selAvailable.options[i] = null;
	selAvailableLength = frmSelect.selAvailable.length;

} loss while moving items between lists box using javascript

I have two list boxes and am able to have the user move items back and fourth 
between them without post back but when the save button is selected (that 
saves data to the dbase from the list box) it appears that there is no data 
in the destination box.  Is there a way to fix this problem using hidden 
controls or some other method, thanks.
Paul G
Software engineer.

4.javascript: adding values to list box


I have a form, and in this form, there are 2 drop down list a text box, one button (labelled "add" )and finally, a listbox.

The question is, when the user clicks on the add button, how do I add the value selected in the drop down list and the text box values and put it into the listbox? After adding to the listbox, the selected value needs to stay in the drop down menu and not get removed. Thanks in advance

5.Split long list of list items

6. populating an asp list box from a simple access lookup list (single column not a table)

7. list box with items for deletion passed from php array

8. Transferring list box items

Return to ASP.NET


Who is online

Users browsing this forum: No registered users and 27 guest