There is a bug with the ASP .NET Web Forms RadioButtonList - if you uncheck all the radios on the client-side (with javascript), after you do a postback the first item in the list will be selected.
Fo开发者_StackOverflow社区r example, try running the following jquery:
$('#myRadioList input').attr('checked', '');
After you do a postback, the first item in the RadioButtonList will be selected.
Anyone know an elegant work around?
It's because by design you will need to choose one option
To uncheck all:
$('input[type=radio]').prop('checked', false);
place it to the end of the page or inside
a $(function() {});
or $(document).ready(function() {});
block
P.S. Use prop
instead of attr
if jQuery 1.6+
.prop() vs .attr()
精彩评论