anup daware

anup daware

  • NA
  • 31
  • 0

Problem with listbox at client side

Apr 18 2006 4:36 AM

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[i].selected)
  {
   var optn = document.createElement("OPTION");
   optn.text = listboxAllFieldEngineers.options[i].value;
   optn.value = listboxAllFieldEngineers.options[i].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