HtmlAnchor.OnPreRender Method
.NET Framework 2.0
Raises the PreRender event and registers client script for generating a postback.
Namespace: System.Web.UI.HtmlControls
Assembly: System.Web (in system.web.dll)
Assembly: System.Web (in system.web.dll)
The following code example demonstrates how to override the OnPreRender method so that it always displays a Title tag in a custom HtmlAnchor server control.
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSL.Controls" Assembly="Samples.AspNet.JSL" %>
<%@ Page Language="VJ#" AutoEventWireup="True" %>
<HTML>
<HEAD>
<title>Custom HtmlAnchor - OnPreRender - VJ# Example</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
Top of Page
<<aspSample:CustomHtmlAnchorOnPreRender
id="HtmlAnchor1"
runat="server"
name="HtmlAnchor1">HtmlAnchor1</aspSample:CustomHtmlAnchorOnPreRender>>
<h3>Custom HtmlAnchor - OnPreRender - VJ# Example</h3>
<P> </P>
<P>Jump to <A href="#HtmlAnchor2">HtmlAnchor2</A> below.</P>
<P> </P><P> </P><P> </P><P> </P>
<P> </P><P> </P><P> </P><P> </P>
<P> </P><P> </P><P> </P><P> </P>
<P> </P><P> </P><P> </P><P> </P>
<P> </P><P> </P><P> </P><P> </P>
<P> </P><P> </P><P> </P><P> </P>
<P> </P><P> </P><P> </P><P> </P>
<P> </P><P> </P><P> </P><P> </P>
<P> </P><P> </P><P> </P><P> </P>
<P> </P><P> </P><P> </P><P> </P>
<P>Jump to <A href="#HtmlAnchor1">HtmlAnchor1</A> above.</P>
<P> </P>Bottom of Page
<<aspSample:CustomHtmlAnchorOnPreRender
id="HtmlAnchor2"
runat="server"
name="HtmlAnchor2">HtmlAnchor2</aspSample:CustomHtmlAnchorOnPreRender>>
</form>
</body>
</HTML>
package Samples.AspNet.JSL.Controls;
public class CustomHtmlAnchorOnPreRender
extends System.Web.UI.HtmlControls.HtmlAnchor
{
protected void OnPreRender(System.EventArgs e)
{
// Call the base OnPreRender method.
super.OnPreRender(e);
// Write out the HtmlAnchor's Title tag
this.set_Title("Text from OnPreRender.");
} //OnPreRender
} //CustomHtmlAnchorOnPreRender
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.
Community Additions
ADD
Show: