CheckBoxList.OnPreRender(EventArgs) 메서드

정의

클라이언트에 렌더링하기 전에 CheckBoxList 컨트롤을 구성합니다.

protected:
 override void OnPreRender(EventArgs ^ e);
protected public:
 override void OnPreRender(EventArgs ^ e);
protected override void OnPreRender (EventArgs e);
protected internal override void OnPreRender (EventArgs e);
override this.OnPreRender : EventArgs -> unit
Protected Overrides Sub OnPreRender (e As EventArgs)
Protected Friend Overrides Sub OnPreRender (e As EventArgs)

매개 변수

e
EventArgs

이벤트 데이터가 포함된 EventArgs입니다.

예제

다음 코드 예제에는 재정의 하는 방법을 보여 줍니다.는 CreateControlStyle 의 새 인스턴스를 항상 반환 되도록 컨트롤을 사용자 지정 서버에서 메서드를 TableStyle 클래스는 CheckBoxList합니다.

<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %>
<%@ Page language="c#" %>
<!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>
    <title>Custom CheckBoxList - OnPreRender - C# Example</title>
  </head>
  <body>
    <form id="Form1" method="post" runat="server">
      <h3>Custom CheckBoxList - OnPreRender - C# Example</h3>

      <aspSample:CustomCheckBoxListOnPreRender
        id="CheckBoxList1" runat="server">
        <asp:ListItem Selected="True">Item 1</asp:ListItem>
        <asp:ListItem>Item 2</asp:ListItem>
        <asp:ListItem>Item 3</asp:ListItem>
        <asp:ListItem>Item 4</asp:ListItem>
        <asp:ListItem>Item 5</asp:ListItem>
        <asp:ListItem>Item 6</asp:ListItem>
      </aspSample:CustomCheckBoxListOnPreRender>

    </form>
  </body>
</html>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %>
<%@ Page language="VB" %>
<!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>
    <title>Custom CheckBoxList - OnPreRender - VB.NET Example</title>
  </head>
  <body>
    <form id="Form1" method="post" runat="server">
      <h3>Custom CheckBoxList - OnPreRender - VB.NET Example</h3>
      <aspSample:CustomCheckBoxListOnPreRender id="CheckBoxList" runat="server"
       RepeatLayout="Table" RepeatColumns="2" CellSpacing="3" CellPadding="3">
                <asp:ListItem  Selected="True">Item 1</asp:ListItem>
                <asp:ListItem>Item 2</asp:ListItem>
                <asp:ListItem>Item 3</asp:ListItem>
                <asp:ListItem>Item 4</asp:ListItem>
                <asp:ListItem>Item 5</asp:ListItem>
                <asp:ListItem>Item 6</asp:ListItem>
            </aspSample:CustomCheckBoxListOnPreRender>
    </form>
  </body>
</html>
using System;
using System.Web;
using System.Web.UI.WebControls;
using System.Security.Permissions;

namespace Samples.AspNet.CS.Controls
{
    [AspNetHostingPermission(SecurityAction.Demand, 
        Level = AspNetHostingPermissionLevel.Minimal)]
    public class CustomCheckBoxListOnPreRender : CheckBoxList
    {
        protected override void OnPreRender(EventArgs e)
        {
            // Run the OnPreRender method on the base class.
            base.OnPreRender(e);

            // Display the Calendar with a 3 point border.
            this.BorderWidth =  Unit.Point(3);
        }
    }
}
Imports System.Web
IMports System.Web.UI.WebControls
Imports System.Security.Permissions

Namespace Samples.AspNet.VB.Controls
    <AspNetHostingPermission(SecurityAction.Demand, _
        Level:=AspNetHostingPermissionLevel.Minimal)> _
    Public Class CustomCheckBoxListOnPreRender
        Inherits System.Web.UI.WebControls.CheckBoxList

        Protected Overrides Sub OnPreRender(ByVal e As EventArgs)

            ' Run the OnPreRender method on the base class.
            MyBase.OnPreRender(e)

            ' Display the CheckBoxList with a 3 point border.
            Me.BorderWidth = Unit.Point(3)
        End Sub
    End Class
End Namespace

설명

메서드는 OnPreRender 주로 클래스에서 파생 되는 사용자 지정 컨트롤의 컨트롤 개발자에 CheckBoxList 의해 사용 됩니다. OnPreRender 메서드를 사용하면 파생 클래스가 대리자를 연결하지 않고 이벤트를 처리 PreRender 할 수 있습니다. 이는 파생 클래스에서 이벤트를 처리하는 기본 방법입니다.

메서드는 OnPreRender 뷰 상태를 저장하고 에 대한 CheckBoxList콘텐츠를 렌더링하기 전에 필요한 사전 렌더링 단계를 수행합니다. 컨트롤에 CheckBoxList 포함된 개별 목록 항목은 현재 AutoPostBack, CausesValidationValidationGroup 값을 사용하여 렌더링하기 위해 초기화됩니다.

상속자 참고

파생 클래스에서 OnPreRender(EventArgs)를 재정의하는 경우 등록된 대리자가 이벤트를 받도록 기본 클래스의 OnPreRender(EventArgs) 메서드를 호출해야 합니다.

적용 대상

추가 정보