Thursday, May 22, 2014
Use of Javascript to allow RadioButton grouping to work in Repeater
1.) JavaScript
<script language="javascript" type="text/javascript">
function RadioSelectionChanged(groupName, current) {
var group = document.getElementsByName(groupName);
for (i = 0; i < group.length; i++) {
//.NET uses a span tag to define the control "name", so the first control in the span control will be the radiobutton if(group[i].childNodes.length > 0 && group[i].childNodes[0].type == 'radio')
group[i].childNodes[0].checked = false;
} current.checked = true;
}</script>
2.) Control
<asp:Repeater ID="Rptr" runat="server">
<ItemTemplate>
<asp:RadioButton ID="Rb" runat="server" onclick="RadioSelectionChanged('GroupName', this);" name="GroupName" />
</ItemTemplate>
</asp:Repeater>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment