zoukankan      html  css  js  c++  java
  • CheckBox控件

    前台代码:

    1 <asp:CheckBox ID="CheckBox1" runat="server" Text ="苹果"/>
    2 <asp:CheckBox ID="CheckBox2" runat="server" Text ="柠檬"/>
    3 <asp:CheckBox ID="CheckBox3" runat="server" Text ="橘子"/>
    4 <asp:CheckBox ID="CheckBox4" runat="server" Text ="桃子"/>
    5 <asp:Button ID="Button2" runat="server" Text="结果" OnClick ="Button2_Click"/>
    6 <asp:Label ID="Label2" runat="server" Text=""></asp:Label>

    后台代码:

     1 /// <summary>
     2 /// Button单击事件
     3 /// </summary>
     4 /// <param name="sender"></param>
     5 /// <param name="e"></param>
     6 protected void Button2_Click(object sender, EventArgs e)
     7 {
     8     string s = string.Empty;
     9 
    10     if (this.CheckBox1.Checked)
    11     {
    12         s += this.CheckBox1.Text + " ";
    13     }
    14     if (this.CheckBox2.Checked)
    15     {
    16         s += this.CheckBox2.Text + " ";
    17     }
    18     if (this.CheckBox3.Checked)
    19     {
    20         s += this.CheckBox3.Text + " ";
    21     }
    22     if (this.CheckBox4.Checked)
    23     {
    24         s += this.CheckBox4.Text + " ";
    25     }
    26 
    27     this.Label2.Text = "你选择的水果有:" + s;
    28 }

    最终效果;

    以上就是CheckBox控件的用法。

  • 相关阅读:
    矿Mac必备软件
    PHP第六课 使用方法数组
    I/O概述和审查操作
    应用程序配置文件
    他毕业两年,博客一年,时间
    苹果公司的回复
    CImage类的介绍与使用
    数据库移植遇到的问题
    MP算法和OMP算法及其思想
    ROR 环境的 搭建
  • 原文地址:https://www.cnblogs.com/KTblog/p/4263339.html
Copyright © 2011-2022 走看看