CheckBox.OnPreRender(EventArgs) Method

Definition

Registers client script for generating postback prior to rendering on the client if AutoPostBack is true.

C#
protected override void OnPreRender(EventArgs e);
C#
protected internal override void OnPreRender(EventArgs e);

Parameters

e
EventArgs

An EventArgs that contains the event data.

Examples

ASP.NET (C#)
<%@ 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 CheckBox - OnPreRender - C# Example</title>
  </head>
  <body>
    <form id="Form1" method="post" runat="server">
      <h3>Custom CheckBox - OnPreRender - C# Example</h3>

      <aspSample:CustomCheckBoxOnPreRender
        id="CheckBox1"
        runat="server"
        text="CheckBox1" />

    </form>
  </body>
</html>
C#
using System.Web;
using System.Security.Permissions;

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

        // Display a LightGray BackColor for the CheckBox.
        this.BackColor = System.Drawing.Color.LightGray;
        }
    }
}

Applies to

Produkt Verzie
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also