Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 632849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:07:16+00:00 2026-05-13T20:07:16+00:00

I have an ASP Page that uses two listboxes and a third party control

  • 0

I have an ASP Page that uses two listboxes and a third party control (Fluent.ListTransfer) to transfer values from one list to the other. Fairly standard stuff:

<td>
    <asp:ListBox ID="ListBoxAvailable" Runat="server"  
        SelectionMode="Multiple" EnableViewState="true">
    </asp:ListBox>
</td>
<td style="vertical-align: middle">
    <a href="#" onclick="<%= ListTransfer1.ClientMoveSelected %>" ><img src="img/RightArrow.jpg" alt=">>"/></a>
    <br />
    <a href="#" onclick="<%= ListTransfer1.ClientMoveBackSelected %>"><img src="img/LeftArrow.jpg" alt="<<"/></a>

</td>
<td>
    <asp:ListBox ID="ListBoxSelected" Runat="server"  
        SelectionMode="Multiple" EnableViewState="true">
    </asp:ListBox>
</td>

On the Controls Page_load event, I set the content of the ‘available’ and ‘selected’ box with some sql:

    protected void Page_Load(object sender, EventArgs e)
    {

        if (IsPostBack)
            return;

        // Some code to work through a recordset, adding values 
        // to the selected or available list boxes

I assumed that on postbacks, the viewstate would take care of the state of listboxes, as changed by the user (after all, they are standard ASP controls). However, both list boxes are blank if I do a postback.

What’s the proper way to maintain the state of the listboxes between postbacks?

Thanks for any help

Ryan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T20:07:17+00:00Added an answer on May 13, 2026 at 8:07 pm

    ViewState is like a “spy” on the client side. Whenever there’s a change in the client side, the ViewState will report back (read: PostBack) the changes to the server so that the server can re-process the page.

    Unfortunately, if we alter contents of a control like ListBox using client-side scripts, ViewState does not see it.

    I guess your Fluent.ListTransfer is a client side function.

    Some solutions:

    The listbox store in ViewState only
    the selected item (I guess only the
    index), not all the items from list,
    so it knows only to restore the
    selected item, not the whole list. Is
    a little bit strange but is logic. To
    mantain in ViewState all the items you
    can write a new ListBox derived from
    ListBox or HtmlSelect, but you must
    handle in the same time the
    possibility that the items from list
    box be modified on client using
    javascript code.


    When a page posts back none of the
    items in a listbox are sent back to
    the server EXCEPT those that are
    SELECTED on the client. This makes
    sense when you think about it. Forget
    about viewstate and all the rest. You
    can select multiple items so make all
    the items you add to listbox 2
    selected.


    Another workaround to this, but not so
    elegant. The basic idea is to record
    all the items on ONE LISTBOX to a
    control, and repopulate the listboxes
    using the control’s value everytime
    the page being posted back. Hopefully
    somebody could come up with something
    better:

    1. Put a HIDDEN input in your web page. Remember to put RUNAT=SERVER
      attribute so that you can reference
      your input from your ASP.NET code
      behind.

    2. In your Javascript, whenever you change the contents of one listbox,
      concatenate all the values – using a
      separator – and put the value into
      your HIDDEN input.

    3. On your Page_Load code, put the code to read the HIDDEN input,
      separate the values, and fill in the
      listboxes.

    Hope this all helps…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.