moving items between list boxes

Discussion in 'ASP .Net' started by Kay, Feb 3, 2004.

  1. Kay

    Kay Guest

    Hello,

    I have two list boxes on my form, one initially displays blank, and through
    javascript it is possible to move items from one box to another, this works
    fine, I followed an article titled "How to move items between Lists with
    Javascript" http://www.devx.com/GetHelpOn/10MinuteSolution/16372. My problem
    is that I also have a dropdown list on the page with autopost back = true,
    and a procedure to handle the text changed event of the dropdown list; my
    problem is as follows: when the user selects an option in the dropdown list
    the form is posted back to the server and certain other processing happens,
    then when the form redisplays, the items that had been moved between the
    list boxes have disappeared. How do I maintain the listboxes on a redisplay?
    I need to do an autopostback on the dropdown list. I also have a save button
    on the form and I know when the user clicks this, I can retrieve the value
    in the listbox by doing a Request.Form("listboxID") on the server, however
    the dropdownlist text changed event will occur before the save button is
    clicked.

    Any idea how I might preserve the users selection in the listboxes when I
    present the screen back to them after the drop down list text changed event?

    Any help appreciated.
    Thanks,
    Kay.
     
    Kay, Feb 3, 2004
    #1
    1. Advertisements

  2. Kay

    Guest Guest

    In this case, because you are doing the manipulation at client side, view state is not updated on page reload and data is being lost from the listbox.

    As a solution, you can either execute dual list transfer at server ...but the drawback is that for every element transfer..it will tax a trip to the server.

    Another solution (which I've implemented for myself) is make a Dual list Server control and manage the view state for listboxes in the server control itself ...This way you can use the same dual listbox control more then once on the same page...

    Hope this gives you direction towards the desired solution....

    Regards
    Avneesh
     
    Guest, Feb 3, 2004
    #2
    1. Advertisements

  3. Kay

    Kay Guest

    Hello Avneesh,

    Thanks for your suggestion, however I am not exactly sure what you mean when
    you say a "Dual list Server control", could you tell me what this means ?

    Thanks,
    Kay.

    state is not updated on page reload and data is being lost from the listbox.
    the drawback is that for every element transfer..it will tax a trip to the
    server.
    Server control and manage the view state for listboxes in the server control
    itself ...This way you can use the same dual listbox control more then once
    on the same page...
     
    Kay, Feb 3, 2004
    #3
  4. Kay

    Guest Guest

    Hi Kay.

    By saying "Dual list Server control" , I ment two listbox controls togather, used to transfer values from left one to right one and vise versa.
    Actually the Custom control with this feature is called "Dual listbox Server control

    Hope it's clear.

    Regard
    Avnees
     
    Guest, Feb 3, 2004
    #4
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.