ValidationSummary.OnPreRender Method

This method supports the .NET Framework infrastructure and is not intended to be used directly from your code.

Raises the PreRender event.

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 following code example demonstrates how to override the OnPreRender method so that it always displays error messages as bold in a custom ValidationSummary server control.

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#" AutoEventWireup="True" %>
<HTML>
	<HEAD>
		<title>Custom ValidationSummary - AddAttributesToRender - VJ# Example</title>
	</HEAD>
	<body>
		<form id="Form1" method="post" runat="server">
			<h3>Custom ValidationSummary - AddAttributesToRender - VJ# Example</h3>

      <TABLE id="Table1" cellPadding="4" cellspacing="0">
        <TR>
          <TD>
            <TABLE id="Table2" cellPadding="4" cellspacing="0" bgColor="#eeeeee">
              <TR>
                <TD colSpan="3"><B>Credit Card Information</B> </TD>
              </TR>
              <TR>
                <TD align="right">Card Type: </TD>
                <TD>
                  <asp:RadioButtonList id="RadioButtonList1" runat="server" RepeatLayout="Flow">
                      <asp:ListItem>MasterCard</asp:ListItem>
                      <asp:ListItem>Visa</asp:ListItem>
                  </asp:RadioButtonList>
                </TD>
                <TD align="center" rowSpan="1">
                  <asp:RequiredFieldValidator 
                    id="RequiredFieldValidator1" 
                    runat="server" 
                    ErrorMessage="Card Type" 
                    Width="100%" 
                    Display="Static" 
                    ControlToValidate="RadioButtonList1">*
                  </asp:RequiredFieldValidator>
                </TD>
              </TR>
              <TR>
                <TD align="right">Card Number: </TD>
                <TD><asp:TextBox id="TextBox1" runat="server"></asp:TextBox></TD>
                <TD>
                  <asp:RequiredFieldValidator 
                    id="RequiredFieldValidator2" 
                    runat="server" 
                    ErrorMessage="Card Number" 
                    Width="100%" 
                    Display="Static" 
                    ControlToValidate="TextBox1">*
                  </asp:RequiredFieldValidator>
                </TD>
              </TR>
              <TR>
                <TD></TD>
                <TD><asp:Button id="Button1" runat="server" text="Validate"></asp:Button></TD>
                <TD></TD>
              </TR>
            </TABLE>
          </TD>
        </TR>
        <TR>
          <TD vAlign="top">
            <aspSample:CustomValidationSummaryAddAttributesToRender
              id="ValidationSummary1" 
              runat="server" 
              DisplayMode="BulletList" 
              HeaderText="You must enter a value in the following fields:" />
          </TD>
        </TR>
      </TABLE>

		</form>
	</body>
</HTML>
...package Samples.AspNet.JSL.Controls; 

public class CustomValidationSummaryAddAttributesToRender
    extends System.Web.UI.WebControls.ValidationSummary
{
    protected void AddAttributesToRender(System.Web.UI.HtmlTextWriter writer)
    {
        // Show the error message as bold.
        writer.AddStyleAttribute(System.Web.UI.HtmlTextWriterStyle.FontWeight,
            "bold");
        // Call the Base's AddAttributesToRender method.
        super.AddAttributesToRender(writer);
    } //AddAttributesToRender
} //CustomValidationSummaryAddAttributesToRender

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: