Image.RenderContents-Methode
Gibt den Inhalt der Bildsteuerung im angegebenen Writer wieder.
Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)
Syntax
'Declaration
Protected Friend Overrides Sub RenderContents ( _
writer As HtmlTextWriter _
)
'Usage
Dim writer As HtmlTextWriter
Me.RenderContents(writer)
protected internal override void RenderContents (
HtmlTextWriter writer
)
protected public:
virtual void RenderContents (
HtmlTextWriter^ writer
) override
protected void RenderContents (
HtmlTextWriter writer
)
protected internal override function RenderContents (
writer : HtmlTextWriter
)
Parameter
- writer
Ein HtmlTextWriter, der den Ausgabestream für die Wiedergabe von HTML-Inhalten auf dem Client darstellt.
Hinweise
Die RenderContents-Methode wird vorwiegend von Steuerelemententwicklern verwendet. Das Image-Steuerelement implementiert die RenderContents-Methode, um die Wiedergabe von untergeordneten Steuerelementen zu überspringen.
Beispiel
Im folgenden Codebeispiel wird das Überschreiben der RenderContents-Methode in einem benutzerdefinierten Serversteuerelement veranschaulicht, sodass nach dem Image immer ein bestimmter Text angezeigt wird.
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %>
<%@ Page Language="VB" AutoEventWireup="True" %>
<HTML>
<HEAD>
<title>Custom Image - RenderContents - VB.NET Example</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<h3>Custom Image - RenderContents - VB.NET Example</h3>
<aspSample:CustomImageRenderContents id="Image1" runat="server"
ImageUrl="https://www.microsoft.com/homepage/gif/bnr-microsoft.gif"
AlternateText="Microsoft Home" />
</form>
</body>
</HTML>
...
<AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class CustomImageRenderContents
Inherits System.Web.UI.WebControls.Image
Protected Overrides Sub RenderContents(ByVal writer As System.Web.UI.HtmlTextWriter)
' Call the base RenderContents method.
MyBase.RenderContents(writer)
' Append some text to the Image.
writer.Write("<BR>Experience Windows Server 2003 and Visual Studio .NET 2003.")
End Sub
End Class
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %>
<%@ Page Language="C#" AutoEventWireup="True" %>
<HTML>
<HEAD>
<title>Custom Image - RenderContents - C# Example</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<h3>Custom Image - RenderContents - C# Example</h3>
<aspSample:CustomImageRenderContents
id="Image1"
runat="server"
ImageUrl="https://www.microsoft.com/homepage/gif/bnr-microsoft.gif"
AlternateText="Microsoft Home" />
</form>
</body>
</HTML>
...
using System.Web;
using System.Security.Permissions;
namespace Samples.AspNet.CS.Controls
{
[AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Minimal)]
public sealed class CustomImageRenderContents : System.Web.UI.WebControls.Image
{
protected override void RenderContents(System.Web.UI.HtmlTextWriter writer)
{
// Call the base RenderContents method.
base.RenderContents(writer);
// Append some text to the Image.
writer.Write("<BR>Experience Windows Server 2003 and Visual Studio .NET 2003.");
}
}
}
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSL.Controls" Assembly="Samples.AspNet.JSL" %>
<%@ Page Language="VJ#" AutoEventWireup="True" %>
<HTML>
<HEAD>
<title>Custom Image - RenderContents - VJ# Example</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<h3>Custom Image - RenderContents - VJ# Example</h3>
<aspSample:CustomImageRenderContents
id="Image1"
runat="server"
ImageUrl="https://www.microsoft.com/homepage/gif/bnr-microsoft.gif"
AlternateText="Microsoft Home" />
</form>
</body>
</HTML>
...
package Samples.AspNet.JSL.Controls;
public class CustomImageRenderContents
extends System.Web.UI.WebControls.Image
{
protected void RenderContents(System.Web.UI.HtmlTextWriter writer)
{
// Call the base RenderContents method.
super.RenderContents(writer);
// Append some text to the Image.
writer.Write("<BR>Experience Windows Server 2003 and "
+ "Visual Studio .NET 2003.");
} //RenderContents
} //CustomImageRenderContents
Plattformen
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
.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.
Versionsinformationen
.NET Framework
Unterstützt in: 2.0, 1.1, 1.0
Siehe auch
Referenz
Image-Klasse
Image-Member
System.Web.UI.WebControls-Namespace
WebControl.RenderContents