ImageButton.AddAttributesToRender Method

Adds the attributes of an ImageButton to the output stream for rendering on the client.

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

protected:
virtual void AddAttributesToRender (
	HtmlTextWriter^ writer
) override
protected void AddAttributesToRender (
	HtmlTextWriter writer
)
protected override function AddAttributesToRender (
	writer : HtmlTextWriter
)

Parameters

writer

The output stream to render on the client.

The OnPreRender method is used primarily by control developers when deriving a custom class from the ImageButton control.

The following code example demonstrates how to override the AddAttributesToRender method in a custom server control so that the ImageButton text always appears with a thin border.

NoteNote

The following code sample uses the single-file code model and may not work correctly if copied directly into a code-behind file. The first part of this code sample must be copied into an empty text file that has an .aspx extension. The second part must be saved as a code file (either .cs for C# or .vb for Visual Basic). For more information on the Web Forms code model, see ASP.NET Web Page Code Model.

No code example is currently available or this language may not be supported.
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSL.Controls" Assembly="Samples.AspNet.JSL" %>
<%@ Page Language="VJ#" AutoEventWireup="True" %>
<HTML>
	<HEAD>
		<title>Custom ImageButton - AddAttributesToRender - VJ# Example</title>
    <script runat="server">
        void ImageButton1_Command(Object sender, CommandEventArgs e) 
        {
            // Redirect to the Microsoft home page.
            get_Response().Redirect("http://www.microsoft.com/");
        } //ImageButton1_Command
    </script>
	</HEAD>
	<body>
		<form id="Form1" method="post" runat="server">
			<h3>Custom ImageButton - AddAttributesToRender - VJ# Example</h3>
			
			<aspSample:CustomImageButtonAddAttributesToRender id="ImageButton1" runat="server" 
			 OnCommand="ImageButton1_Command" AlternateText="Microsoft Home" 
			 ImageUrl="http://www.microsoft.com/homepage/gif/bnr-microsoft.gif" />

		</form>
	</body>
</HTML>
...package Samples.AspNet.JSL.Controls; 

public class CustomImageButtonAddAttributesToRender
    extends System.Web.UI.WebControls.ImageButton
{
    protected void AddAttributesToRender(System.Web.UI.HtmlTextWriter writer)
    {
        // Show the ImageButton with a thin border.
        writer.AddStyleAttribute("border-width", "thin");
        // Call the Base's AddAttributesToRender method.
        super.AddAttributesToRender(writer);
    } //AddAttributesToRender
} //CustomImageButtonAddAttributesToRender

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

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

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show: