Image.AddAttributesToRender-Methode
Diese Methode unterstützt die .NET Framework-Infrastruktur und ist nicht für die direkte Verwendung in Code bestimmt.
Fügt dem Ausgabestream die Attribute eines Image zur Wiedergabe auf dem Client hinzu.
Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)
Syntax
'Declaration
Protected Overrides Sub AddAttributesToRender ( _
writer As HtmlTextWriter _
)
'Usage
Dim writer As HtmlTextWriter
Me.AddAttributesToRender(writer)
protected override void AddAttributesToRender (
HtmlTextWriter writer
)
protected:
virtual void AddAttributesToRender (
HtmlTextWriter^ writer
) override
protected void AddAttributesToRender (
HtmlTextWriter writer
)
protected override function AddAttributesToRender (
writer : HtmlTextWriter
)
Parameter
- writer
Ein System.Web.UI.HtmlTextWriter, der den Ausgabestream enthält, der mit dem Clientbrowser wiedergegeben werden soll.
Beispiel
Im folgenden Codebeispiel wird das Überschreiben der AddAttributesToRender-Methode in einem benutzerdefinierten Serversteuerelement veranschaulicht, sodass Image immer mit einem dünnen Rahmen angezeigt wird.
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %>
<%@ Page Language="VB" AutoEventWireup="True" %>
<HTML>
<HEAD>
<title>Custom Image - AddAttributesToRender - VB.NET Example</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<h3>Custom Image - AddAttributesToRender - VB.NET Example</h3>
<aspSample:CustomImageAddAttributesToRender 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 CustomImageAddAttributesToRender
Inherits System.Web.UI.WebControls.Image
Protected Overrides Sub AddAttributesToRender(ByVal writer As System.Web.UI.HtmlTextWriter)
' Show the Image with a thin border.
writer.AddStyleAttribute("border-width", "thin")
' Call the Base's AddAttributesToRender method.
MyBase.AddAttributesToRender(writer)
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 - AddAttributesToRender - C# Example</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<h3>Custom Image - AddAttributesToRender - C# Example</h3>
<aspSample:CustomImageAddAttributesToRender
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 CustomImageAddAttributesToRender : System.Web.UI.WebControls.Image
{
protected override void AddAttributesToRender(System.Web.UI.HtmlTextWriter writer)
{
// Show the Image with a thin border.
writer.AddStyleAttribute("border-width","thin");
// Call the Base's AddAttributesToRender method.
base.AddAttributesToRender(writer);
}
}
}
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSL.Controls" Assembly="Samples.AspNet.JSL" %>
<%@ Page Language="VJ#" AutoEventWireup="True" %>
<HTML>
<HEAD>
<title>Custom Image - AddAttributesToRender - VJ# Example</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<h3>Custom Image - AddAttributesToRender - VJ# Example</h3>
<aspSample:CustomImageAddAttributesToRender
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 CustomImageAddAttributesToRender
extends System.Web.UI.WebControls.Image
{
protected void AddAttributesToRender(System.Web.UI.HtmlTextWriter writer)
{
// Show the Image with a thin border.
writer.AddStyleAttribute("border-width", "thin");
// Call the Base's AddAttributesToRender method.
super.AddAttributesToRender(writer);
} //AddAttributesToRender
} //CustomImageAddAttributesToRender
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