Button.RenderContents-Methode
Rendert den Inhalt des Steuerelements im angegebenen Writer.
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 System.Web.UI.HtmlTextWriter, der den Ausgabestream für das Rendering des HTML-Inhalts auf dem Client darstellt.
Beispiel
Das folgende Codebeispiel veranschaulicht das Überschreiben der RenderContents-Methode in einem benutzerdefinierten Serversteuerelement, damit nach einem benutzerdefinierten Button-Serversteuerelement immer Text angezeigt wird.
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %>
<%@ Page language="VB" %>
<HTML>
<HEAD>
<title>Custom Button - RenderContents - VB.NET Example</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<h3>Custom Button - RenderContents - VB.NET Example</h3>
<aspSample:CustomButtonRenderContents id="Button1" runat="server" Text="Button" />
</form>
</body>
</HTML>
...
Imports System.Web
Imports System.Security.Permissions
Namespace Samples.AspNet.VB.Controls
<AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class CustomButtonRenderContents
Inherits System.Web.UI.WebControls.Button
Protected Overrides Sub RenderContents(ByVal writer As System.Web.UI.HtmlTextWriter)
MyBase.RenderContents(writer)
' Append some text after the button.
writer.Write("<br>Click this button for more information.")
End Sub
End Class
End Namespace
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %>
<%@ Page language="c#" %>
<HTML>
<HEAD>
<title>Custom Button - RenderContents - C# Example</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<h3>Custom Button - RenderContents - C# Example</h3>
<aspSample:CustomButtonRenderContents
id="Button1"
runat="server"
Text="Button" />
</form>
</body>
</HTML>
...
using System.Web;
using System.Security.Permissions;
namespace Samples.AspNet.CS.Controls
{
[AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class CustomButtonRenderContents : System.Web.UI.WebControls.Button
{
protected override void RenderContents(System.Web.UI.HtmlTextWriter writer)
{
// Call the base RenderContents method.
base.RenderContents(writer);
// Append some text after the button.
writer.Write("<br>Click this button for more information.");
}
}
}
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSL.Controls" Assembly="Samples.AspNet.JSL" %>
<%@ Page language="VJ#" %>
<HTML>
<HEAD>
<title>Custom Button - RenderContents - VJ# Example</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<h3>Custom Button - RenderContents - VJ# Example</h3>
<aspSample:CustomButtonRenderContents
id="Button1"
runat="server"
Text="Button" />
</form>
</body>
</HTML>
...
package Samples.AspNet.JSL.Controls;
public class CustomButtonRenderContents extends System.Web.UI.WebControls.Button
{
protected void RenderContents(System.Web.UI.HtmlTextWriter writer)
{
// Call the base RenderContents method.
super.RenderContents(writer);
// Append some text after the button.
writer.Write("<br>Click this button for more information.");
} //RenderContents
} //CustomButtonRenderContents
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
Button-Klasse
Button-Member
System.Web.UI.WebControls-Namespace
System.Web.UI.HtmlTextWriter