This documentation is archived and is not being maintained.

LinkButton.OnPreRender Method

Raises the PreRender event.

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

Protected Friend Overrides Sub OnPreRender ( _
	e As EventArgs _


Type: System.EventArgs
An EventArgs object that contains the event data.

The OnPreRender method notifies the LinkButton control to perform any necessary prerendering steps prior to saving view state and rendering content to the client.

The following code example demonstrates how to override the OnPreRender method so that a border is never displayed in a custom LinkButton control.

<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %>
<%@ Page Language="VB" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="" >
        <title>Custom LinkButton - OnPreRender - VB.NET Example</title>
        <script runat="server">
            Sub LinkButton1_Command(sender As Object, e As CommandEventArgs)
                ' Redirect to the Microsoft home page.
            End Sub
        <form id="Form1" method="post" runat="server">
            <h3>Custom LinkButton - OnPreRender - VB.NET Example</h3>

            <aspSample:CustomLinkButtonOnPreRender id="LinkButton1" 
             runat="server" OnCommand="LinkButton1_Command" 
             ToolTip="Microsoft Home">Microsoft Corp.</aspSample:CustomLinkButtonOnPreRender>



<AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class CustomLinkButtonOnPreRender
    Inherits System.Web.UI.WebControls.LinkButton

    Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs)

        ' Run the OnPreRender method on the base class.

        ' Always display the LinkButton without a border.
        Me.BorderWidth = System.Web.UI.WebControls.Unit.Point(0)
    End Sub
End Class

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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