CheckBox 생성자

정의

CheckBox 클래스의 새 인스턴스를 초기화합니다.

public:
 CheckBox();
public CheckBox ();
Public Sub New ()

예제

참고

다음 코드 샘플 단일 파일 코드 모델을 사용 하 고 코드 숨김 파일에 직접 복사 하는 경우 제대로 작동 하지 않을 수 있습니다. 이 코드 샘플.aspx 확장명이 있는 빈 텍스트 파일에 복사 해야 합니다. Web Forms 코드 모델에 대 한 자세한 내용은 참조 하세요. ASP.NET Web Forms 페이지 코드 모델합니다.


<%@ Page Language="C#" AutoEventWireup="True" %>

<!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 Constructor Example </title>
<script runat="server">

      void Page_Load(Object sender, EventArgs e)
      {

         // Create new CheckBox control.
         CheckBox NewCheckBox = new CheckBox();
         NewCheckBox.ID="FeatureCheckBox";
         NewCheckBox.Text="Enable feature";
         NewCheckBox.AutoPostBack = true;

         // Register the event-handling method for the CheckedChanged event. 
         NewCheckBox.CheckedChanged += new EventHandler(this.Check_Change);

         // Add the control to the Controls collection of the
         // PlaceHolder control. 
         Place.Controls.Clear();
         Place.Controls.Add(NewCheckBox);

      }

      void Check_Change(Object sender, EventArgs e)
      {

         // Retrieve the CheckBox control from the PlaceHolder control.
         CheckBox check = (CheckBox)Place.FindControl("FeatureCheckBox");

         // Display the appropriate message based on the state of the
         // CheckBox control. 
         if(check.Checked)
         {
            Message.Text = "Feature enabled.";
         }
         else
         {
            Message.Text = "Feature disabled.";
         }

      }

   </script>

</head>

<body>

   <form id="form1" runat="server">

      <h3> CheckBox Constructor Example </h3>

      Click the check box.

      <br /><br />

      <asp:Placeholder id="Place" 
           runat="server"/>

      <br /><br />

      <asp:Label id="Message" 
           runat="server"/>

   </form>

</body>

</html>

<%@ Page Language="VB" AutoEventWireup="True" %>

<!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 Constructor Example </title>
<script runat="server">

      Sub Page_Load(sender As Object, e As EventArgs)

         ' Create new CheckBox control.
         Dim NewCheckBox As CheckBox = New CheckBox()
         NewCheckBox.ID="FeatureCheckBox"
         NewCheckBox.Text="Enable feature"
         NewCheckBox.AutoPostBack = True

         ' Register the event handling method for the CheckedChanged event. 
         AddHandler NewCheckBox.CheckedChanged, AddressOf Check_Change

         ' Add the control to the Controls collection of the
         ' PlaceHolder control. 
         Place.Controls.Clear()
         Place.Controls.Add(NewCheckBox)

      End Sub

      Sub Check_Change(sender As Object, e As EventArgs)

         ' Retrieve the CheckBox control from the PlaceHolder control.
         Dim check As CheckBox = _
            CType(Place.FindControl("FeatureCheckBox"), CheckBox)

         ' Display the appropriate message based on the state of the
         ' CheckBox control. 
         If check.Checked Then
         
            Message.Text = "Feature enabled."
     
         Else
         
            Message.Text = "Feature disabled."
         
         End If


      End Sub

   </script>

</head>

<body>

   <form id="form1" runat="server">

      <h3> CheckBox Constructor Example </h3>

      Click the check box.

      <br /><br />

      <asp:Placeholder id="Place" 
           runat="server"/>

      <br /><br />

      <asp:Label id="Message" 
           runat="server"/>

   </form>

</body>

</html>

설명

이 생성자를 사용 하 여 만들고의 새 인스턴스를 초기화 하는 CheckBox 클래스입니다.

적용 대상