简单教程
提交运行
代码编辑器:
<script runat="server"> Sub submit(Sender As Object, e As EventArgs) if red.Checked then Label1.Text="You selected " & red.Text elseIf green.Checked then Label1.Text="You selected " & green.Text elseIf blue.Checked then Label1.Text="You selected " & blue.Text end if End Sub </script> <!DOCTYPE html> <meta charset="utf-8" /> <form runat="server"> Select your favorite color: <br> <asp:RadioButton id="red" Text="Red" Checked="True" GroupName="colors" runat="server"/> <br> <asp:RadioButton id="green" Text="Green" GroupName="colors" runat="server"/> <br> <asp:RadioButton id="blue" Text="Blue" GroupName="colors" runat="server"/> <br> <asp:Button text="Submit" OnClick="submit" runat="server"/> <p><asp:Label id="Label1" runat="server"/></p> </form>
运行结果: