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

Discussion in 'ASP .Net Web Controls' started by Joe Abou Jaoude, Nov 18, 2004.

  1. 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

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Joe Abou Jaoude, Nov 18, 2004
    #1
    1. Advertising

  2. Hi Joe,

    Use hidden control to store the state of the listboxes

    Rgds,
    Thiruppathi S
    "Joe Abou Jaoude" <> wrote in message
    news:...
    >
    > 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
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Thiruppathi S, Nov 18, 2004
    #2
    1. Advertising

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


    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Joe Abou Jaoude, Nov 18, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sumit
    Replies:
    1
    Views:
    327
    Rajesh.V
    Oct 16, 2003
  2. monika
    Replies:
    2
    Views:
    324
    monika
    Apr 25, 2005
  3. =?Utf-8?B?cGF0cmlja2RyZA==?=

    Client side changes not reflected in page

    =?Utf-8?B?cGF0cmlja2RyZA==?=, Feb 1, 2007, in forum: ASP .Net
    Replies:
    24
    Views:
    1,056
    =?Utf-8?B?cGF0cmlja2RyZA==?=
    Mar 28, 2007
  4. chandru
    Replies:
    1
    Views:
    643
    bruce barker
    Jul 20, 2007
  5. Patrice
    Replies:
    0
    Views:
    802
    Patrice
    Apr 12, 2010
Loading...

Share This Page