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

My scenario is this: I have two listbox's, one that contains all my database
My WPF Listbox should have two columns. The one on the right should have
I have a page with two ListBox controls. The page contains a list of
You can only have one form runat=server per page apparently. My page has one
I have pane with two grid and there is a listbox in both grid.
I have two collections displayed in my WPF application, and I'd like to have
For my site, I have a list of users and a list of events.
I need a single scrollable surface that contains two bound lists. At first, I
I have a WPF program built in C#, and part of it's function is
The user sees a form with many controls, including a list box. He selects

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.