admin管理员组文章数量:1426347
I have an existing RadioButtonList
on a page and need to set the second button to be checked as default instead of the first.
I probably need to do it with javascript
on the page as I cannot edit the original control.
<list:RadioButtonList runat="server" Class="class" Text="text"
AlternativeText="alternative text" />
Any idea how i can detect the control and set its default value?
I have an existing RadioButtonList
on a page and need to set the second button to be checked as default instead of the first.
I probably need to do it with javascript
on the page as I cannot edit the original control.
<list:RadioButtonList runat="server" Class="class" Text="text"
AlternativeText="alternative text" />
Any idea how i can detect the control and set its default value?
Share Improve this question asked Feb 1, 2013 at 11:56 dizzytri99erdizzytri99er 9309 silver badges25 bronze badges1 Answer
Reset to default 4If you use ASP.NET you can set the following:
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem Selected="True" ></asp:ListItem>
<asp:ListItem></asp:ListItem>
<asp:ListItem></asp:ListItem>
<asp:ListItem></asp:ListItem>
<asp:ListItem></asp:ListItem>
</asp:RadioButtonList>
I've added the attribute Selected="True", so you always have a default value selected.
You can also do this in code:
if (RadioButtonList1.SelectedIndex == -1) //-1 is the indication of none selected
{
RadioButtonList1.SelectedIndex = 2; //select index 2 (can also be value or text)
}
本文标签: caffecting existing RadioButtonList to set a default valueStack Overflow
版权声明:本文标题:c# - affecting existing RadioButtonList to set a default value - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745472850a2659829.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论