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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:47:02+00:00 2026-05-15T23:47:02+00:00

I am using ASP.NET and in my .aspx page I have the following code,

  • 0

I am using ASP.NET and in my .aspx page I have the following code, and, based on the selection, I am displaying the appropriate divs. It’s working great, as is, but the question is: How do I get the value (whatever selected by user) on code-behind?

<select id="filterResultsBy"  >
    <option value="">Select...</option>
    <option value="Date">Date</option>
    <option value="Subject">Subject</option> 
    <option value="Status">Status</option>
</select>

If I add runat="server" or use the server asp:DropDownList control, jQuery does not work.

$('#ddlFilter').change(function(){ 
   var sel = $(this).val(); 
   if(sel === 'DATE'){ 
     hideAll();// a function to hide all the divs first 
     $('#divDateRangeSearch').show(); 
   } else if(sel === 'SUBJECT'){ 
     ///so on... 
   } 
}); 
  • 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-15T23:47:02+00:00Added an answer on May 15, 2026 at 11:47 pm

    In ASP.NET the usual convention is to use server side controls which work better with the Postback model. So you could use the equivalent:

    <asp:DropDownList ID="filterResultsBy" runat="server" CssClass="ddlFilter">
        <asp:ListItem Value="" Text="Select..." />
        <asp:ListItem Value="Date" Text="Date" />
        <asp:ListItem Value="Subject" Text="Subject" />
        <asp:ListItem Value="Status" Text="Status" />
    </asp:DropDownList>
    

    which would allow you to access the filterResultsBy variable in the code behind and retrieve the currently selected value. To make this work with client scripting libraries such as jQuery add a class and use a class selector instead of id selector because of the name mangling that occurs in ASP.NET server side controls:

    $('.ddlFilter').change(function() {
        var sel = $(this).val(); 
        if(sel === 'DATE') { 
            hideAll(); // a function to hide all the divs first 
            $('#divDateRangeSearch').show(); 
        } else if (sel === 'SUBJECT') { 
            ///so on... 
        } 
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using ASP.NET AJAX. I create a .aspx page that is based on a
I'm using asp.net with url rewrite . Inside Page Load I have the following
I am using FckEditor in Create.aspx page in asp.net mvc application. Since I need
Using a reference from... http://weblogs.asp.net/pwelter34/archive/2006/05/03/444961.aspx I have a serializable generic dictionary. One thing I
I have a asp.net sitemap with single level dropdown menu. I am using following
I am using JQuery mobile in asp.net web form website. I have the following
I'm working with the following code that is contained in a .ASPX.CS page... img
I am working on an ASP.NET page that we, in code impersonate the requesting
In my ASP.NET page I have the following method: public static void UpdatePage(string accessCode,
I have the following structure in an aspx page: <asp:Panel ID=pnlCust runat=server> <asp:GridView ID=gvMaster

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.