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控件的用法。

  • 相关阅读:
    Swift之 ? 和 !
    objective-c工程使用swift
    NSMethodSignature和NSInvocation的用法
    NSTimer
    iOS 的 XMPPFramework
    计算string高度
    python学习:猜数字小游戏
    python 各种控制语句
    ③ 小程序的代码组成
    ③ 组件&props
  • 原文地址:https://www.cnblogs.com/KTblog/p/4263339.html
Copyright © 2011-2022 走看看