I have a serverside dropdownlist and I am accessing it’s id in jquery like this
$(‘#<%=ddldropdownlist.clientID%>’)
I have a asp:LinkButton inside a gridview and I want to access it’s client ID.
when I do as above in jquery it doesn’t work
I think that’s not the correct way since the server control is inside another server control
Could someone please help
You have a few of options:
The most common would be to assign a custom class or attribute to the button that you can use as a selector.
The other way would be to implement the
OnDataBindingevent for the button and then assign theClientIDof the control from theOnDataBindingsenderto your Jquery call in this function for each control assuming you are trying to hookup some Jquery to your button.You could also use the
OnDataBindingmethod to build up a hidden field with a list ofClientIDnames.The best solution is probably to get a selector working but there are cases where the
OnDataBindingworks great as well.