<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>Si el código anterior no ejecuta ninguno de los botones de radio seleccionados, si el usuario hace clic, entonces está seleccionando, pero quiero seleccionar de forma predeterminada la primera opción y luego, si el usuario selecciona cualquier opción, seleccione solo esa opción, esta página es como seleccionar la dirección. Por favor, alguien ayuda en esto.
Esto se debe a que no está activando el clic en la carga de su página. Prueba esto :-
document.getElementById("RadioButton").click();