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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:33:53+00:00 2026-05-17T20:33:53+00:00

So I have a cascading dropdown of sorts, but using List Boxes. When an

  • 0

So I have a cascading dropdown of sorts, but using List Boxes. When an item is selected in the first ListBox, the second ListBox is populated with items based on the first selection (this is done using a jQuery AJAX call). Here’s what I got:

$('#<%= lbEvents.ClientID %>').change(function() {
    var selectedValues = $('#<%= lbEvents.ClientID %>').val();
    var json = '{ events: [' + selectedValues.join(',') + '] }';

    $.ajax({
        type: "POST",
        url: 'Default.aspx/PopulateAttendees',
        data: json,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: OnAttendeesPopulated
    });
});



function OnAttendeesPopulated(response) {
    var attendees = response.d;
    var attendeesList = $("#<%= lbAttendees.ClientID %>");

    attendeesList.children().remove();

    $.each(attendees, function() {
        attendeesList.append($("<option></option>").val(this['Value']).html(this['Text']));
    });
}


//Populated on PageLoad
<asp:ListBox ID="lbEvents" runat="server" SelectionMode="Multiple" />

<asp:ListBox ID="lbAttendees" runat="server" SelectionMode="Multiple" />

<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" />

At first, I was getting an error on the button’s click event because lbAttendees was being loaded dynamically, so I had to set EnableEventValidation to false.

I don’t get the error now, but in the button’s click event, I can only access the data in lbEvents, but not lbAttendees; lbAttendees is empty in the click event. I assume I need to store the data from lbAttendees in ViewState.

How can I store the data from lbAttendees in ViewState so I can access it in the click event?

  • 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-17T20:33:53+00:00Added an answer on May 17, 2026 at 8:33 pm

    You can’t really do this (at least not easily). The issue here is that ajax and asp.net forms don’t really mix well together. As I see it you you have two options:

    • Hook into the 2nd listbox with JavaScript and then use AJAX with some api (REST?) to save the items as they are clicked on. (Basically make the 2nd listbox 100% AJAX enabled.) This is a hard solution — you have to deal with lots of UI events and use case, but very cool if you get it working.

    • Add some JavaScript which runs when the button is clicked this code will write the selected values to a hidden textbox. Then your server-side code can read the values (comma separated) out of the hidden textbox.

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

Sidebar

Related Questions

I have a cascading dropdown list on my page. The first dropdown contains a
I have cascading dropdowns to bring the list of contacts for the selected company.
I have written a cascading drop down list using JQuery. The code that I
I'm planning to create a cascading dropdown list of Country--> State/Province--->Zip code using geonames.
I have a list of drop down lists populated form a database(using ASP.NET). These
I have a cascading dropdown with jQuery which is using PHP to retrieve its
I have cascading data-bound combo boxes, however, if the second of the two boxes
I am having great difficultly testing cascading dropdown boxes with Selenium. I would like
I have a number of cascading drop down boxes that allow users to filter
I have a page that has several ListBox es that have some cascading filtering

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.