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

  • Home
  • SEARCH
  • 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 friends i am trying to get a list of user id and want
Hello I have this problem with PyQt4-dev-tools that include: * a user interface compiler
Hello I am working with a simulator that uses rcS scripts to boot, this
Hello Guys I am trying to figure out why i am gettings this error
Hello i have this code var queue = new BlockingCollection<int>(); queue.Add(0); var producers =
Hello fellow developers... just to make sure, I want to ask this question: How
Hello i been trying to get a tokenizer to work using the boost library
hello i have a desktop application that communicate with a wcf service that i
Hello i have tableview with many objects in it. If i want to add
Hello I have this query... if (isset($_REQUEST['deletePost'])) { $q = $dbc -> prepare(DELETE FROM

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.