CheckBox控件
生活随笔
收集整理的這篇文章主要介紹了
CheckBox控件
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
?
前臺(tái)代碼:
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="結(jié)果" OnClick ="Button2_Click"/> 6 <asp:Label ID="Label2" runat="server" Text=""></asp:Label>?
后臺(tái)代碼:
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控件的用法。
?
轉(zhuǎn)載于:https://www.cnblogs.com/KTblog/p/4263339.html
總結(jié)
以上是生活随笔為你收集整理的CheckBox控件的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 发布不到一年 微软《帝国时代4》Stea
- 下一篇: CWPP(云工作负载保护平台)