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 6069093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:47:06+00:00 2026-05-23T09:47:06+00:00

I have two listboxes, two html input tags and one .NET submit button on

  • 0

I have two listboxes, two html input tags and one .NET submit button on an webpage.

// The two listboxes
<asp:ListBox ID="lbViewOptions_Hidden" runat="server" Rows="7" Width="110px"></asp:ListBox>
<asp:ListBox ID="lbViewOptions_Show" runat="server" Rows="7" Width="110px"></asp:ListBox>

// The two html input tag
<input id="ibtnRight" type="image" src="images/move_right.png" style="height:16px;width:16px;border-width:0px;" />
<input id="ibtnLeft" type="image" src="images/move_left.png" style="height:16px;width:16px;border-width:0px;" />

// The .NET submit button
<asp:Button ID="btnApplyViewOptions" runat="server" Text="Apply" CssClass="submit" onclick="btnApplyViewOptions_Click" />

I have the following jQuery functions for the click events of the input tags, which simply move items back and forth between the two listboxes. These functions work just fine and move items back and forth between the listboxes.

$('#ibtnRight').click(function ($e) {
    $("select[id$='lbViewOptions_Hidden'] option:selected").appendTo(
        $("select[id$='lbViewOptions_Show']"));
    $("select[id$='lbViewOptions_Hidden'] option:selected").remove();

    $e.preventDefault();
});

$('#ibtnLeft').click(function ($e) {
    $("select[id$='lbViewOptions_Show'] option:selected").appendTo(
        $("select[id$='lbViewOptions_Hidden']"));
    $("select[id$='lbViewOptions_Show'] option:selected").remove();

    $e.preventDefault();
});

The listboxes are loaded during the page_load event with various items that are dynamic, thus my reason for using ASP.NET listbox controls instead of just hardcoding an HTML select tag with the various items. My problem is this: due to the fact that the listboxes are .NET controls and I’m using jQuery to move items back and forth between the them, any changes made to them does not persist through a postback.

For example, assume that listbox lbViewOptions_Hidden has two items in it: “Foo #1” and “Foo #2”. If I select item “Foo #2” and click the input button to move it to listbox lbViewOptions_Show, then it moves over as it should, and I now have item “Foo #1” in the first listbox and item “Foo #2” in the second listbox. However, if I click on the .NET button btnApplyViewOptions to submit back to the server, the second listbox has no items and all of the items are still in the first listbox.

How do I go about fixing this problem? I assume that it has something to do with the ViewState, but I’m not positive about it. Thanks in advance for any help that I get on this!

  • 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-23T09:47:07+00:00Added an answer on May 23, 2026 at 9:47 am

    You are going to have to either use Ajax to call a WebMethod server side to update the controls by storing the changes in the session … then upon postback update the controls with the session values.

    Or you can use a hidden field that has the runat="server" attribute added to it, to store the changes between the lists and then grab the changes on post back and update the controls that way.

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

Sidebar

Related Questions

I have a listbox on an HTML form with a Submit button. The listbox
I Have two listboxes when I drag One item from the source listbox I
I have two ListBoxes, lstAvailableColors and lstSelectedColors. Between each listbox are two buttons, Add
I have a vertical StackPanel with two elements: a Button and a ListBox. How
I have two asp:ListBox. The ID's are Authors and AuthorsSelected. Authors listbox is loaded
My scenario is this: I have two listbox's, one that contains all my database
I have two listboxes that I am dragging one item from to the other.
If I have two listboxes, with a button between them, how do I update
I have two listboxes and two buttons. Each listbox is in its own div
I have two listBoxes. The first listbox contains the list of traffic violations. When

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.