JQuery asp dropdownlist
I have one control with some asp form elements, but how do I get the form elements in my other control. I usually do jQuery ('# <% = MyDropDownList.ClientID%>). Val (), but this is not possible since it is in another control. How can I access an element without hardcoding it?
So to summarize: Control 1: Asp: DropDownList Control 2: Requires access to the value in asp: DropDownlist from control 1 via jQuery.
+1
a source to share
2 answers
If the names are unique, you can use a selector that matches the name at the end of the identifier.
$('[id$="DropDownList1"]').val();
This will match all controls whose id ends with DropDownList1
and gets the value of the first. If the name is unique, then this will be your other dropdown list.
+1
a source to share