listbox changes on the client side aren't reflected on the server side

J

Joe Abou Jaoude

hi all,

I have 2 listboxes in my web page. one listbox has 5 items when the page
is loaded, the other one is empty. The user then add fields from the
filled listbox to the empty listbox. this is done successfully using
javascript.
when the page is submitted i want to check the items that the user added
to the listbox.
however i always get that the first listbox has 5 items and the second
listbox is empty. It's like the user changes wasn't submitted to the
server.
the 2 listboxes has the EnableViewState = true.

the javascript that i use to add items to the listbox is the following:
(i use the listbox.remove method and the new option () )

function AddItem() {
if(window.document.Form1.lstAll.selectedIndex == -1) return;
var item =
window.document.Form1.lstAll.options[window.document.Form1.lstAll.select
edIndex].text;
var i = Form1.lstSort.length;
Form1.lstSort.options = new Option(item, i);
window.document.Form1.lstAll.remove(window.document.Form1.lstAll.selecte
dIndex);
}

thanx
 
T

Thiruppathi S

Hi Joe,

Use hidden control to store the state of the listboxes

Rgds,
Thiruppathi S
 
J

Joe Abou Jaoude

yea, this is a work around to resolve the problem. but shouldn't the
listbox control itself save its state ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top