1

i want user control's dropdownlist selected item from page. when i try to get dropdownlist id it doesn't return correct id. Have you any idea about what i can get dropdownlist id?

var e = $("#<%=ddlCategory.ClientID%> option:selected").val();

                 alert(e);
 <blogControl:UCCategory  ID="ddlCategory" runat="server"  />
1
  • Is <blogControl:UCCategory /> a UserControl that contains a DropDownList? If so, you'd need to expose the UserControl's DropDownList ClientID, rather than the UserControl's ClientID. You could do this by putting a public read-only property in the UserControl that returns its DropDownList's ClientID, then use that in your jquery selector. Commented May 17, 2013 at 21:45

1 Answer 1

1

i solve this problem to use this code,

C#

public string GetCategoryClientID()
{
    return   ddlCategory.ClientId;
} 

Js

var e = document.getElementById("<%=GetCategoryClientID() %>");
alert(e.options[e.selectedIndex].value);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.