CheckBoxList.OnPreRender メソッド
アセンブリ: System.Web (system.web.dll 内)

Dim e As EventArgs Me.OnPreRender(e)

OnPreRender メソッドは、カスタム コントロールを CheckBoxList クラスから派生させる場合に、主にコントロールの開発者によって使用されます。OnPreRender メソッドを使用すると、デリゲートを結び付けずに派生クラスで PreRender イベントを処理できます。派生クラスでイベントを処理する場合は、この手法をお勧めします。
OnPreRender メソッドは、ビューステートを保存して CheckBoxList の内容を表示する前に、必要な事前の表示処理手順をすべて実行します。CheckBoxList コントロールの個々のリスト項目は、現在の AutoPostBack、CausesValidation、および ValidationGroup の各値を使用して、表示用に初期化されます。
継承時の注意 派生クラスで OnPreRender をオーバーライドする場合は、登録されているデリゲートがイベントを受け取ることができるように、基本クラスの OnPreRender メソッドを呼び出してください。
カスタム サーバー コントロールの CreateControlStyle メソッドをオーバーライドし、CheckBoxList の TableStyle クラスについて、常に新しいインスタンスが返されるようにする方法のコード例を次に示します。
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %> <%@ Page language="VB" %> <HTML> <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> <br /><span space="preserve">...</span><br />Imports System 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
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %> <%@ Page language="c#" %> <HTML> <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> <br /><span space="preserve">...</span><br />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); } } }
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSL.Controls" Assembly="Samples.AspNet.JSL" %> <%@ Page language="VJ#" %> <HTML> <HEAD> <title>Custom CheckBoxList - OnPreRender - VJ# Example</title> </HEAD> <body> <form id="Form1" method="post" runat="server"> <h3>Custom CheckBoxList - OnPreRender - VJ# 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> <br /><span space="preserve">...</span><br />package Samples.AspNet.JSL.Controls; public class CustomCheckBoxListOnPreRender extends System.Web.UI.WebControls.CheckBoxList { protected void OnPreRender(System.EventArgs e) { // Run the OnPreRender method on the base class. super.OnPreRender(e); // Display the Calendar with a 3 point border. this.set_BorderWidth(System.Web.UI.WebControls.Unit.Point(3)); } //OnPreRender } //CustomCheckBoxListOnPreRender

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


CheckBoxList クラス
CheckBoxList メンバ
System.Web.UI.WebControls 名前空間
その他の技術情報
CheckBox Web サーバー コントロールおよび CheckBoxList Web サーバー コントロール
Weblioに収録されているすべての辞書からCheckBoxList.OnPreRender メソッドを検索する場合は、下記のリンクをクリックしてください。

- CheckBoxList.OnPreRender メソッドのページへのリンク