webform1.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="test4_5.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged">
<asp:ListItem Value="0">A 1+1=2</asp:ListItem>
<asp:ListItem Value="1">B 1+1=3</asp:ListItem>
<asp:ListItem Value="2">C 1+1=4</asp:ListItem>
<asp:ListItem Value="3">D 1+1=1</asp:ListItem>
</asp:RadioButtonList>
<br />
<asp:Label ID="Label1" runat="server" Text="Label" Visible="False"></asp:Label>
</div>
</form>
</body>
</html>
webform.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace test4_5
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
Label1.Visible = true;
if (int.Parse(RadioButtonList1.SelectedValue) == 0)
{
Label1.Text = "选择正确";
}
else
{
Label1.Text = "选择错误";
}
}
}
}