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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:25:01+00:00 2026-05-28T08:25:01+00:00

Hello i’m trying to use autocomplete dropdownlist plugin that name is ufd. Anyway, I

  • 0

Hello i’m trying to use autocomplete dropdownlist plugin that name is ufd.
Anyway, I have dropdownlist and i want to get this selected value (or text) on codebehind click_event.
if i can remove all selected attr from dropdownlist and add selected attr to selected option, this will work.But this removeAttr doesn’t work:( Please help me.

       $(function () {
        var element = $("#DropDownList1");
        $(element).change(function () {
        $(element).find('option').removeAttr('selected'); //this is not working
        $(element + "option[value=" + $(element).val() + "]").attr("selected", "selected");
        });
       });

    <asp:DropDownList ID="DropDownList1" runat="server">
    </asp:DropDownList>
    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />

codebehind:

    protected void Page_Load(object sender, EventArgs e)
    {
        using (TalepService tService = new TalepService())
        {
            DropDownList1.DataSource = tService.ddlTalepDurumDoldur();
            DropDownList1.DataTextField = "talepDurumu";
            DropDownList1.DataValueField = "talepDurumID";
            DropDownList1.DataBind();
        }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        string text = DropDownList1.SelectedItem.Text;
        string value = DropDownList1.SelectedValue;
    }
  • 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-28T08:25:02+00:00Added an answer on May 28, 2026 at 8:25 am

    You are creating jQuery objects from jQuery objects, which is having an issue on this line (I’m assuming):

    $(element + "option[value=" + $(element).val() + "]").attr("selected", "selected");
    

    Because element is a jQuery object (keyword, object) and you are adding a string to that object.

    Try this:

    $(function () {
        var element = $("#DropDownList1");
        element.change(function () {
            var theVal = element.val();//get the current value since it will be removed on the next line
            element.find('option').removeAttr('selected'); //this is not working
            element.find("option[value=" + theVal + "]").attr("selected", "selected");
        });
    });
    

    Here is a demo: http://jsfiddle.net/LjhwW/1/

    While creating this demo I realized the same thing as “am not i am” (in the comments). Why are you manually changing the selected option element for the change event, the browser will do this anyway.

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

Sidebar

Related Questions

Hello I want to get Accurate location so that i have used following link
Hello I have like this 2 tables class User public int UserId{get;set;} { ....
Hello the problem I'm having is this, I have a landing page (event.php) that
Hello I've got this query to get users by email, which is an unique
Hello I am trying to get status of battery of the device programmatically. So
Hello I have following column in SSRS Report. Column Name(Title) Mehta, Natasha(18)----its Title+(count) value
Hello guys i have been using JavaFx scene builder to build a gui that
Hello all and thanks for the attention! I have a problem that must both
Hello everyone I have converted a project in C# to F# that paints the
Hello I have a custom control. This custom control has it's DataContext set to

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.