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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:50:51+00:00 2026-05-30T22:50:51+00:00

I have a simple jquery function which I use to show/hide some divs. The

  • 0

I have a simple jquery function which I use to show/hide some divs. The function works when I use a regular html dropdown list but not when using an ASP control, and I need it to work with the ASP control because I need to perform some actions on it in the code-behind.

DropDown Lists code:

<asp:DropDownList ID="SelectAccount" runat="server">
        <asp:ListItem Value="Social_Worker">Social Worker</asp:ListItem>
        <asp:ListItem>Sponsor</asp:ListItem>
    </asp:DropDownList>

    <select name="" id="SelectAccount1" onclick="return SelectAccount_onclick()">
        <option value="sponsor">Sponsor</option>
        <option value="social_worker">Social Worker</option>
    </select>​

jquery code:

$(document).ready(function () {
    var det = $("#SponsorDetails");
    var all = $("#AllDetails");
    $(all).hide();
    $(det).hide();

    $("#SelectAccount").change(function () {
        //hide social worker and sponsor stuff
        var value = $("#SelectAccount option:selected").val();
        if (value == "social_worker") {
            //show social worker stuff
            $("#AllDetails").show("slow");
            $("#SponsorDetails").hide("slow");
        } else {
            //show sponsor stuff
            $("#AllDetails").show("slow");
            $("#SponsorDetails").show("slow");
        } 
    });
  });

Why won’t the same jquery work with the ASP control?

  • 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-30T22:50:53+00:00Added an answer on May 30, 2026 at 10:50 pm

    This is probably because the ID of the asp control is a server side id whereas the id of a normal control is client side and they do not always match especially if they are nested or in master pages.

    To make this work you could modify your script, if your script is in the page, on the server side something like this:

    $("#<%=SelectAccount.ClientID %>").change(function () { ... }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jQuery script, which is filtering an html select list. It works
I have written a simple jQuery.ajax function which loads a user control from the
I have a simple javascript that uses $.ajax() from JQuery which works great for
I have this simple function: <script type=text/javascript> //<![CDATA[ jQuery(function($){ function here(b){alert(b);} ; here(6); });
I have a simple jquery animation on a div, which is inside a div,
I have a simple jquery/ajax request to the server which returns the structure and
I have created a simple JQuery script with hovering effect on some links. The
I have a simple bit of jQuery which displays the row below the current
I have a pretty simple image switcher, which I use for manual images switcher
I have an ajax function which call a servlet to get list of products

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.