However, I need to do this with jQuery, because I'm using a CSS class for my selector (stupid ASP.NET
How can I do it with jQuery? Update So as it turns out, I had it right the first time with:
When I put an alert just above it works fine, but when I remove the alert and let it run at full speed, I get the error Could not set the selected property. Invalid Index I'm not sure if it's a bug with jQuery or Internet Explorer 6 (I'm guessing Internet Explorer 6), but it's terribly annoying.
This behavior is in jQuery versions 1.2 and above. You most likely want this:
With hidden field you need to use like this:
Just an FYI, you don't need to use CSS classes to accomplish this. You can write the following line of code to get the correct control name on the client:
ASP.NET will render the control ID correctly inside the jQuery.
Just try with
and not with
I use an extend function to get client ids, like so:
Then you can call ASP.NET controls in jQuery like this: