复选空件和复选组控件(CheckBox和CheckBoxList).aspx
<%
...
@ Page Language="C#" AutoEventWireup="true" CodeFile="复选空件和复选组控件(CheckBox和CheckBoxList).aspx.cs" Inherits="复选空件和复选组控件_CheckBox和CheckBoxList_"
%>
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head runat ="server" >
< title > 复选空件和复选组控件(CheckBox和CheckBoxList) </ title >
</ head >
< body >
< form id ="form1" runat ="server" >
< div >
复选控件的基本属性都和上一个例子差不多,但是复选空间没有GroupName属性。 < br />
< asp:CheckBox ID ="cb1" runat ="server" Style ="position: relative" AutoPostBack ="True" OnCheckedChanged ="cb1_CheckedChanged" Text ="文字具有上划线" />
< br />
< br />
< asp:CheckBox ID ="cb2" runat ="server" Style ="position: relative" AutoPostBack ="True" OnCheckedChanged ="cb2_CheckedChanged" Text ="文字具有下划线" />< br />
< br />
< asp:CheckBox ID ="cb3" runat ="server" Style ="position: relative" AutoPostBack ="True" OnCheckedChanged ="cb3_CheckedChanged" Text ="文字具有删除线" />
< br />
< br />
< asp:Label ID ="Label1" runat ="server" Style ="position: relative" Text ="测试使用的文字" ></ asp:Label >< br />
< br />
注意要将每一个CheckBox都设置为AutoPostBack哦 < br />
< br />
下面的类子我们还是使用上面的文字,用CheckBoxList做 < br />
< br />
< asp:CheckBoxList ID ="CheckBoxList1" runat ="server" AutoPostBack ="True" OnSelectedIndexChanged ="CheckBoxList1_SelectedIndexChanged"
Style ="position: relative" >
< asp:ListItem > 文字具有上划线 </ asp:ListItem >
< asp:ListItem > 文字具有下划线 </ asp:ListItem >
< asp:ListItem > 文字具有删除线 </ asp:ListItem >
</ asp:CheckBoxList >< br />
< br />
注意要将每一个CheckBoxList设置为AutoPostBack哦 </ div >
</ form >
</ body >
</ html >
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head runat ="server" >
< title > 复选空件和复选组控件(CheckBox和CheckBoxList) </ title >
</ head >
< body >
< form id ="form1" runat ="server" >
< div >
复选控件的基本属性都和上一个例子差不多,但是复选空间没有GroupName属性。 < br />
< asp:CheckBox ID ="cb1" runat ="server" Style ="position: relative" AutoPostBack ="True" OnCheckedChanged ="cb1_CheckedChanged" Text ="文字具有上划线" />
< br />
< br />
< asp:CheckBox ID ="cb2" runat ="server" Style ="position: relative" AutoPostBack ="True" OnCheckedChanged ="cb2_CheckedChanged" Text ="文字具有下划线" />< br />
< br />
< asp:CheckBox ID ="cb3" runat ="server" Style ="position: relative" AutoPostBack ="True" OnCheckedChanged ="cb3_CheckedChanged" Text ="文字具有删除线" />
< br />
< br />
< asp:Label ID ="Label1" runat ="server" Style ="position: relative" Text ="测试使用的文字" ></ asp:Label >< br />
< br />
注意要将每一个CheckBox都设置为AutoPostBack哦 < br />
< br />
下面的类子我们还是使用上面的文字,用CheckBoxList做 < br />
< br />
< asp:CheckBoxList ID ="CheckBoxList1" runat ="server" AutoPostBack ="True" OnSelectedIndexChanged ="CheckBoxList1_SelectedIndexChanged"
Style ="position: relative" >
< asp:ListItem > 文字具有上划线 </ asp:ListItem >
< asp:ListItem > 文字具有下划线 </ asp:ListItem >
< asp:ListItem > 文字具有删除线 </ asp:ListItem >
</ asp:CheckBoxList >< br />
< br />
注意要将每一个CheckBoxList设置为AutoPostBack哦 </ div >
</ form >
</ body >
</ html >
复选空件和复选组控件(CheckBox和CheckBoxList).aspx
using
System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class 复选空件和复选组控件_CheckBox和CheckBoxList_ : System.Web.UI.Page
... {
protected void Page_Load(object sender, EventArgs e)
...{
}
protected void cb1_CheckedChanged(object sender, EventArgs e)
...{
if (this.cb1.Checked == true)
...{
this.Label1.Font.Overline = true;
}
else
...{
this.Label1.Font.Overline = false;
}
}
protected void cb2_CheckedChanged(object sender, EventArgs e)
...{
if (this.cb2.Checked == true)
...{
this.Label1.Font.Underline = true;
}
else
...{
this.Label1.Font.Underline = false;
}
}
protected void cb3_CheckedChanged(object sender, EventArgs e)
...{
if (this.cb3.Checked == true)
...{
this.Label1.Font.Strikeout = true;
}
else
...{
this.Label1.Font.Strikeout = false;
}
}
protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
...{
if (this.CheckBoxList1 .Items [0].Selected )
...{
this.Label1.Font.Overline = true;
}
else
...{
this.Label1.Font.Overline = false;
}
if (this.CheckBoxList1 .Items [1].Selected )
...{
this.Label1.Font.Underline = true;
}
else
...{
this.Label1.Font.Underline = false;
}
if (this.CheckBoxList1 .Items [2].Selected )
...{
this.Label1.Font.Strikeout = true;
}
else
...{
this.Label1.Font.Strikeout = false;
}
}
}
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class 复选空件和复选组控件_CheckBox和CheckBoxList_ : System.Web.UI.Page
... {
protected void Page_Load(object sender, EventArgs e)
...{
}
protected void cb1_CheckedChanged(object sender, EventArgs e)
...{
if (this.cb1.Checked == true)
...{
this.Label1.Font.Overline = true;
}
else
...{
this.Label1.Font.Overline = false;
}
}
protected void cb2_CheckedChanged(object sender, EventArgs e)
...{
if (this.cb2.Checked == true)
...{
this.Label1.Font.Underline = true;
}
else
...{
this.Label1.Font.Underline = false;
}
}
protected void cb3_CheckedChanged(object sender, EventArgs e)
...{
if (this.cb3.Checked == true)
...{
this.Label1.Font.Strikeout = true;
}
else
...{
this.Label1.Font.Strikeout = false;
}
}
protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
...{
if (this.CheckBoxList1 .Items [0].Selected )
...{
this.Label1.Font.Overline = true;
}
else
...{
this.Label1.Font.Overline = false;
}
if (this.CheckBoxList1 .Items [1].Selected )
...{
this.Label1.Font.Underline = true;
}
else
...{
this.Label1.Font.Underline = false;
}
if (this.CheckBoxList1 .Items [2].Selected )
...{
this.Label1.Font.Strikeout = true;
}
else
...{
this.Label1.Font.Strikeout = false;
}
}
}