Problem with listbox at client side

A

Anup

Hi Group,

In my application there is a very common functionality, where two list
box and present and items are moved between them on button clicks when
selected,

This I am doing client side,
Client side code is like this ->

function
assignInspector(listboxAllFieldEngineers,listBoxAssignedFieldEngineers)
{
i=0;
while(i<listboxAllFieldEngineers.length)
{
if(listboxAllFieldEngineers.options.selected)
{
var optn = document.createElement("OPTION");
optn.text = listboxAllFieldEngineers.options.value;
optn.value = listboxAllFieldEngineers.options.value;
listBoxAssignedFieldEngineers.options.add(optn);
listboxAllFieldEngineers.remove(i);
continue;
}
i++;
}
return false;
}


Here two list boxes are passed from .CS file ->

buttonAddSelected.Attributes.Add("onclick","return
assignInspector(listboxAllFieldEngineers,listBoxAssignedFieldEngineers);");



PROBELM:-

Items move from one listbox to other perfectly but when listboxes are
accessed through .cs file, they show there previous state,

e.g. ->

say LeftListBox is having 4 items and RightListBox is having 2
elements,
now I select and move two items from left and move them ro right and
one of previously present items from right to left on button click,

the client side operation is carried out perfectly,

But when I try to use the Items in RightListBox in .CS
file,RightListBox.Items.Count returns only '2' instead of '3', which
are previously present in the RightListBox.


Please tell me where I am going wrong(Using ASP.NET 1.x).


Thanks and Regards,

Anup Daware
 
B

bruce barker \(sqlwork.com\)

when the browser post the page, it only sends the selecteditem value for a
listbox back to the server. therefore the server has no way of knowing the
changes made in the list. you should add a hidden field that the client
script updates with the current contents of the lists, then the serverside
code can process this hidden field to update the lists on the serverside.

-- bruce (sqlwork.com)
 
A

Anup

Hi Bruce,

Thank you for valuable reply,
Can you please guide me how do I use a hidden field, particularly in
this case, as I am novice to C# and ASP.NET.

Thanks,

Anup
 

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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top