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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:31:20+00:00 2026-05-23T12:31:20+00:00

In my ASP.NET applications, I have a server-side HTML select control. <select id=CompanyDropDown runat=server

  • 0

In my ASP.NET applications, I have a server-side HTML select control.

<select id="CompanyDropDown" runat="server" style="width:330px">
</select>

I then have a link on my page that runs a JavaScript function that populates this control, and also selects the “current” item. I can see this is working because the list has all the items and the correct one is selected.

However, when the page posts back in response to a button click.

<asp:Button runat="server" ID="btnSaveCompany" Text="Save" 
    onclick="btnSaveCompany_Click" />

CompanyDropDown.Value is empty, and it contains no items. Any suggestions on how I can see the selected value on postback?

(Note: I tried using an ASP.NET DropDown control, but that fails postback validation when the control has items that were added after the page was rendered.)

  • 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-23T12:31:21+00:00Added an answer on May 23, 2026 at 12:31 pm

    Because items added to the list using JavaScript aren’t part of the viewstate, they cannot be retrieved server side. If you are only trying to get the selected value, put a server-side hidden field on your page and set its value using JavaScript each time the selection of the drop-down is changed:

    jQuery script:

    $('#CompanyDropDown').change(function() {
        $('#inpSelectValue').val($(this).val());
    });
    

    Hidden field markup:

    <input runat="server" id="inpSelectValue" clientidmode="static" type="hidden" />
    

    The value of the hidden field will be carried to the server on post back. Refer to it to retrieve the value of the selected item. Be sure to add clientidmode="static" to your drop down as well to keep the rendered id of your controls set to the id you assign in the ASPX page (i.e., CompanyDropDown rather than parentContainer_CompanyDropDown):

    <select id="CompanyDropDown" runat="server" style="width:330px"
        clientidmode="static" />
    

    Alternatively, you could use AJAX to tell the server you are adding each dynamically generated list item or changing the selection. I would only do this if you needed to maintain a list of items in addition to which one is selected.

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

Sidebar

Related Questions

I've been developing traditional ASP.NET applications with server side ASP.NET controls and code behind
Here's the scenario: You have an ASP.Net application supported by a Microsoft SQL Server
We have a ASP.Net 2.0 web application up and running with the server in
Suppose you have 2 different ASP.NET applications in IIS. Also, you have some ASCX
I have been working with Visual Studio (WinForm and ASP.NET applications using mostly C#)
I have two web applications and both are developed in ASP.NET. Now I want
I have recently upgraded some of my web applications to ASP.NET 3.5 by installing
I have some existing (largish) ASP.NET web applications that people are starting to visit
I have 6 servers that i need to deploy my ASP.NET web application to.
I have to deploy my ASP.NET application into two seperated IIS servers. My application

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.