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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:39:52+00:00 2026-05-11T16:39:52+00:00

I have a listbox with runat=server Items are added to this listbox on the

  • 0
  1. I have a listbox with runat=server
    1. Items are added to this listbox on the client side, using javascript
    2. I would want to retrieve the items on the server side on the click of a button

The problem is in the Buttons’s server side click handler, I cannot see the new items added to the listbox. Only the items that were there on page_load are displayed. How do i accomplish what i want to do

Edit 1

My Code Is like this

 protected void Page_Load(object sender, EventArgs e)
    {


        if (!IsPostBack)
        {
            if (ViewState["gameID"] == null)
            {
                //Populate Listbox
                //Set gameid in viewstate
            }

            //Add javascript handlers to buttons
            btnSomeButton.Attributes.Add("onclick", "aJavaScriptFunction"); 

        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        ListItemCollection x = ListBoxRanks.Items;
        //Here items is has just those items that are added to the listbox on page load

    }
  • 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-11T16:39:53+00:00Added an answer on May 11, 2026 at 4:39 pm

    Ah when abstractions leek 🙂

    Web server controls are serialised to view state before the response is sent, the control is recreated on postback and the options all put back from view state.

    When you add option items client side they are not added to viewstate. The only way is to use your own hidden field to serialise client side additions and read them on postback or ajax the additions serverside.

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

Sidebar

Related Questions

I have a list box: <asp:ListBox ID="lstAppointment" runat="server"></asp:ListBox> I want to make it multicolumn.
i have a list: <asp:ListBox ID=lstProblems runat=server SelectionMode=Multiple></asp:ListBox> and i am populating it this
I have a list box control: <asp:ListBox runat=server id=lbox autoPostBack=true /> The code behind
I have a ListBox which displays items of variable height. I want to show
I have a list box in my aspx page: <asp:ListBox ID=lstTreatmentProvider runat=server SelectionMode=Multiple Width=175px
I have the following listbox on aspx page. <asp:ListBox runat=server ID=lbA Visible=true SelectionMode=Multiple DataTextField=A_FACTOR
I have 4 server side ListBox controls. All of them have their Enabled property
I have a ListBox that has a style defined for ListBoxItems. Inside this style,
I have a listbox where the items contain checkboxes: <ListBox Style={StaticResource CheckBoxListStyle} Name=EditListBox> <ListBox.ItemTemplate>
I have a Listbox which I add items to it in the OnClick event.

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.