复选空件和复选组控件(CheckBox和CheckBoxList)

复选空件和复选组控件(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 >

复选空件和复选组控件(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;
        }

    }

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值