<div id="ManageAddressPage" runat="server">
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<div id="EditAddressPage" style="border: solid 1px LightGray;background-color:#f5faff">
<div style="padding:15px">
<asp:Label ID="lblAddressID" runat="server" Text='<%# Eval("AddressID") %>' Visible = "false" />
<asp:RadioButton ID="RadioButton" runat="server" Onclick="javascript:singleselection(this.id)" ></asp:RadioButton>
<asp:Label ID="lblContactName" style="margin-right:15px" runat="server" Text='<%# Eval("Name") %>' />
<asp:Label ID="lblCountry" runat="server" Text='<%# Eval("PhoneNumber") %>' />
</div>
<div style="margin-left:10px;width:90%;margin-bottom:20px;">
<asp:Label ID="lbladdress" runat="server" Text='<%# Eval("Address") %>' />
</div>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
<script type="text/javascript" >
function singleselection(rbid) {
var rbutton = document.getElementById(rbid);
var rbuttonlist = document.getElementsByTagName("input")
for (i = 0; i < rbuttonlist.length; i++) {
if (rbuttonlist[i].type == "radio" && rbuttonlist[i].id !== rbutton.id) {
rbuttonlist[i].checked = false;
}
}
}
</script>
If the above code runs none of the radio button selected , if user clicks then its selecting , but i want by default select 1st option and then if user select any option then select only that option, this page is like selecting the address. Please someone help on this.
That is because you are not triggering the click on your page load. Try this :-
document.getElementById("RadioButton").click();