重慶分公司,新征程啟航
為企業(yè)提供網(wǎng)站建設(shè)、域名注冊、服務(wù)器等服務(wù)
為企業(yè)提供網(wǎng)站建設(shè)、域名注冊、服務(wù)器等服務(wù)
本篇文章為大家展示了ASP.NET中如何使用CheckBox復(fù)選框控件,內(nèi)容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。
創(chuàng)新互聯(lián)主要從事成都做網(wǎng)站、成都網(wǎng)站設(shè)計、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)納雍,十多年網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):13518219792單獨使用CheckBox,先來看看它的屬性
屬性 | 描述 | .NET |
---|---|---|
AutoPostBack | 規(guī)定在 Checked 屬性已改變后,是否立即向服務(wù)器回傳表單。默認是 false。 | 1.0 |
CausesValidation | 規(guī)定點擊 Button 控件時是否執(zhí)行驗證。 | 2.0 |
Checked | 規(guī)定是否已選中該復(fù)選框。 | 1.0 |
InputAttributes | 該 CheckBox 控件的 Input 元素所用的屬性名和值的集合。 | 2.0 |
LabelAttributes | 該 CheckBox 控件的 Label 元素所用的屬性名和值的集合。 | 2.0 |
runat | 規(guī)定該控件是服務(wù)器控件。必須被設(shè)置為 "server"。 | 1.0 |
Text | 與復(fù)選框關(guān)聯(lián)的文本標簽。 | 1.0 |
TextAlign | 與復(fù)選框關(guān)聯(lián)的文本標簽的對齊方式。(right 或 left) | 1.0 |
ValidationGroup | 在 CheckBox 控件回發(fā)到服務(wù)器時要進行驗證的控件組。 | 2.0 |
OnCheckedChanged | 當 Checked 屬性被改變時,被執(zhí)行函數(shù)的名稱。 |
讓我們來做個簡單的示例來演示一下
前臺代碼:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="CheckBox.aspx.cs" Inherits="WebControls_CheckBox" %>
后臺代碼:
using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class WebControls_CheckBox : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { lblState.Text = string.Empty; if (chkSport.Checked) { lblState.Text = lblState.Text + chkSport.Text; } if (chkSport2.Checked) { if (lblState.Text.Length == 0) { lblState.Text = chkSport2.Text; } else { lblState.Text = lblState.Text + "," + chkSport2.Text; } } if (chkSport3.Checked) { if (lblState.Text.Length == 0) { lblState.Text = chkSport2.Text; } else { lblState.Text = lblState.Text + "," + chkSport3.Text; } } } }
運行效果:
上述內(nèi)容就是ASP.NET中如何使用CheckBox復(fù)選框控件,你們學(xué)到知識或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識儲備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。