RadioButton.aspx中的代码:
<%@ Page language="c#" Codebehind="RadioButton.aspx.cs" AutoEventWireup="false" Inherits="WebApplication1.RadioButton" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>RadioButton</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<h3>&lt;RadioButton示例</h3>
<form id="Form1" method="post" runat="server">
<HR style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 48px" width="100%" SIZE="1">
<asp:radiobuttonlist id="RadioButtonList1" style="Z-INDEX: 102; LEFT: 16px; POSITION: absolute; TOP: 64px"
runat="server" Width="488px" Height="72px">
<asp:ListItem Selected>项目1</asp:ListItem>
<asp:ListItem>项目2</asp:ListItem>
<asp:ListItem>项目3</asp:ListItem>
<asp:ListItem>项目4</asp:ListItem>
<asp:ListItem>项目5</asp:ListItem>
</asp:radiobuttonlist><asp:label id="Label1" style="Z-INDEX: 103; LEFT: 16px; POSITION: absolute; TOP: 264px" runat="server"
Width="344px" Height="56px" BackColor="#C0C0FF" BorderColor="Gray" BorderWidth="1px"></asp:label><asp:button id="Button1" style="Z-INDEX: 104; LEFT: 176px; POSITION: absolute; TOP: 224px" Text="提交"
Runat="server"></asp:button><asp:checkbox id="CheckBox1" style="Z-INDEX: 105; LEFT: 24px; POSITION: absolute; TOP: 200px"
runat="server" Text="表格布局"></asp:checkbox>
<asp:CheckBox id="CheckBox2" style="Z-INDEX: 106; LEFT: 24px; POSITION: absolute; TOP: 232px"
runat="server" Text="水平布局"></asp:CheckBox></form>
</body>
</HTML>
RadioButton.aspx.cs中的代码
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;namespace WebApplication1
{
/// <summary>
/// RadioButton 的摘要说明。
/// </summary>
public class RadioButton : System.Web.UI.Page
{
protected System.Web.UI.WebControls.RadioButtonList RadioButtonList1;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.CheckBox chkLayout;
protected System.Web.UI.WebControls.CheckBox chkDirection;
protected System.Web.UI.WebControls.CheckBox CheckBox1;
protected System.Web.UI.WebControls.CheckBox CheckBox2;
protected System.Web.UI.WebControls.Label Label1;

private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面 } #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{    
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.CheckBox1.CheckedChanged += new System.EventHandler(this.CheckBox1_CheckedChanged);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
Label1.Text="您选择了:"+RadioButtonList1.SelectedItem.Text;
} private void CheckBox1_CheckedChanged(object sender, System.EventArgs e)
{
if(CheckBox1.Checked)
{
RadioButtonList1.RepeatLayout = RepeatLayout.Table;
}
else
{
RadioButtonList1.RepeatLayout = RepeatLayout.Flow;
}
}
}
}