HtmlAnchor.OnPreRender(EventArgs) Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
PreRender Menaikkan peristiwa dan mendaftarkan skrip klien untuk menghasilkan postback.
protected:
override void OnPreRender(EventArgs ^ e);
protected public:
override void OnPreRender(EventArgs ^ e);
protected override void OnPreRender (EventArgs e);
protected internal override void OnPreRender (EventArgs e);
override this.OnPreRender : EventArgs -> unit
Protected Overrides Sub OnPreRender (e As EventArgs)
Protected Friend Overrides Sub OnPreRender (e As EventArgs)
Parameter
Contoh
Contoh kode berikut menunjukkan cara mengambil alih OnPreRender metode sehingga selalu menampilkan Title tag dalam kontrol server kustom HtmlAnchor .
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %>
<%@ Page Language="C#" AutoEventWireup="True" %>
<!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 HtmlAnchor - OnPreRender - C# 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 - C# 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>
<%@ 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"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Custom HtmlAnchor - OnPreRender - Visual Basic 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 - Visual Basic 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>
using System.Web;
using System.Security.Permissions;
namespace Samples.AspNet.CS.Controls
{
[AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class CustomHtmlAnchorOnPreRender : System.Web.UI.HtmlControls.HtmlAnchor
{
protected override void OnPreRender(System.EventArgs e)
{
// Call the base OnPreRender method.
base.OnPreRender(e);
// Write out the HtmlAnchor control's Title tag.
this.Title = "Text from OnPreRender.";
}
}
}
Imports System.Web
Imports System.Security.Permissions
Namespace Samples.AspNet.VB.Controls
<AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class CustomHtmlAnchorOnPreRender
Inherits System.Web.UI.HtmlControls.HtmlAnchor
Protected Overrides Sub OnPreRender(ByVal e As System.EventArgs)
' Call the base OnPreRender method.
MyBase.OnPreRender(e)
' Write out the HtmlAnchor control's Title tag.
Me.Title = "Text from OnPreRender."
End Sub
End Class
End Namespace
Berlaku untuk
Berkolaborasi dengan kami di GitHub
Sumber untuk konten ini dapat ditemukan di GitHub, yang juga dapat Anda gunakan untuk membuat dan meninjau masalah dan menarik permintaan. Untuk informasi selengkapnya, lihat panduan kontributor kami.