I am attempting to use a jquery drowndown checklist control.
Following some simple examples, I was able to get the control working properly in a stand alone aspx page (the control renders, and works as it should), but I cant get it to work in a master/content page (the control is not rendering.. instead the select element, stays as a regular select element).
Here is the code (i tried to paste it here, but couldnt get it to format properly):
http://droidso.blogspot.com/2012/03/dropdownchecklist-code.html
what am i doing wrong?
It turns out that when you use Master pages in asp.net, asp.Net will replace the IDs of your controls to ensure that the html thats rendered has all id’s which are unique (where as the master page and content page can have controls with the same id). The problem with that is that jQuery cant find the control based on id because the id has changed. As a workaround to this I decided to select by class name.
e.g.
Instead of
$("#s1").dropdownchecklist();instead use
$(".s1class").dropdownchecklist();where “s1class” is the name of the css class on the select control.
An alternative which also works is what tvanfosson suggested in the comments above (using jQuery matches selector to find id’s which “end with” the string you specify). The problem with that is having to ensure the id endings are unique (which I find harder then simply uniquely naming the controls css classes).