Set a CSS class on an ASP.NET RadioButtonList ListItem Set a CSS class on an ASP.NET RadioButtonList ListItem asp.net asp.net

Set a CSS class on an ASP.NET RadioButtonList ListItem


Yes, RadioButtonList renders horrible HTML.

Anyway, it's still easy to get them from jQuery.

Try

$('span.myclass input:radio')

Above will get all the radio buttons inside the span with class 'myclass'.


An alternative you may want to try to do is change your CSS class to accomindate the Server Control Rendering.

So in your CSS instead of the following:

.myClass { ... }

You Use this:

.myClass input { ... }

I don't know if you can set the class attribute (via class or CSSClass) in a declarative manner; however, the above should give you a work around.


untested

$('.myclass input:radio').each(function() {        this.css({'style-name':'style-value'}))};

once the list is rendered, you can possibly manipulate the css client side using the above statement.