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

  • Home
  • SEARCH
  • 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'm planning to create a cascading dropdown list of Country--> State/Province--->Zip code using geonames.
I am having great difficultly testing cascading dropdown boxes with Selenium. I would like
So I have a UserControl with some cascading DropDownList s on it. Selecting from
I have a Postgresql database on which I want to do a few cascading
Have just started using Google Chrome , and noticed in parts of our site,
Have just started using Visual Studio Professional's built-in unit testing features, which as I
I have an MVC application. Say for example if we have a dropdown Cars
I have a list of controller names and would then have a list of
I have 4 Ajax Toolkit cascading dropdowns on my page. Under certain conditions on

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.