<%@ Page Language="C#" Debug="true" %> <script runat="server"> void Button1_OnClick(object sender, EventArgs e) { if(Radio1.Checked == true) { this.lblText1.Text = "Radio 1 is checked"; } else if(Radio2.Checked == true) { this.lblText1.Text = "Radio 2 is checked"; } else if(Radio3.Checked == true) { this.lblText1.Text = "Radio 3 is checked"; } } </script> <html> <head> </head> <body> <form runat="server"> <input type="radio" id="Radio1" name="GrpRadio" runat="server"/>Option 1<br> <input type="radio" id="Radio2" name="GrpRadio" runat="server"/>Option 2<br> <input type="radio" id="Radio3" name="GrpRadio" runat="server"/>Option 3<br> <input id="Button1" type="button" OnServerClick="Button1_OnClick" value="Button" runat="server" /> <hr /> <asp:Label id="lblText1" runat="server"></asp:Label> </form> </body> </html>
ช่วยกันสนับสนุนรักษาเว็บไซต์ความรู้แห่งนี้ไว้ด้วยการสนับสนุน Source Code 2.0 ของทีมงานไทยครีเอท