Copy codeThe Code is as follows:
<Pre class = "html" name = "code"> <% -- Body code -- %>
<Div>
<Asp: RadioButtonList ID = "RadioButtonList1" runat = "server">
<Asp: ListItem Value = "A"> a </asp: ListItem>
<Asp: ListItem Value = "B"> B </asp: ListItem>
</Asp: RadioButtonList>
<Asp: RadioButton ID = "RadioButton1" GroupName = "RBtn" Text = "male" runat = "server" Checked = "true"/>
<Asp: RadioButton ID = "RadioButton2" GroupName = "RBtn" Text = "female" runat = "server"/>
<Asp: Button ID = "Button1" runat = "server" Text = "Button" OnClientClick = "button?clientclick ()"> </asp: Button>
</Div> </pre>
Copy codeThe Code is as follows:
<Pre class = "csharp" name = "code"> <% -- Head code -- %>
<Script language = "javascript" type = "text/javascript" src = "js/jquery-1.9.1.js"> </script>
<Script language = "javascript" type = "text/javascript">
Function Button1_ClientClick ()
{
Alert ($ ("input [name = 'radiobuttonlist1 ']: checked "). val (); // If none are selected, "undefined" is displayed. If any is selected, the corresponding Value is displayed.
If (document. getElementById ("RadioButton1"). checked = true) // if RadioButton1 is selected
{
Alert ($ ("# RadioButton1: checked"). val (); // The RadioButton1 prompt is displayed.
Alert ($ ("# RadioButton2: checked"). val (); // The undefined
Alert ($ ("# RadioButton1: checked"). val () = "RadioButton1"); // true is displayed
}
Return false; // you do not need to upload the data to the background.
}
</Script>
</Pre>