CheckBoxList.OnPreRender Method

Configures the CheckBoxList control prior to rendering on the client.

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)

protected public:
virtual void OnPreRender (
	EventArgs^ e
) override
protected void OnPreRender (
	EventArgs e
)
protected internal override function OnPreRender (
	e : EventArgs
)

Parameters

e

An EventArgs that contains the event data.

The OnPreRender method is used primarily by control developers, when deriving a custom control from the CheckBoxList class. The OnPreRender method allows derived classes to handle the PreRender event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

The OnPreRender method performs any necessary prerendering steps prior to saving view state and rendering content for the CheckBoxList. The individual list items contained in the CheckBoxList control are initialized for rendering using the current AutoPostBack, CausesValidation, and ValidationGroup values.

Notes to Inheritors When overriding OnPreRender in a derived class, be sure to call the base class's OnPreRender method so that registered delegates receive the event.

The following code example demonstrates how to override the CreateControlStyle method in a custom server control so that it always returns a new instance of the TableStyle class for the CheckBoxList.

No code example is currently available or this language may not be supported.
<%@ 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>
...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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show: