ImageButton.TagKey Property

Gets the HtmlTextWriterTag value that corresponds to the ImageButton control.

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

protected:
virtual property HtmlTextWriterTag TagKey {
	HtmlTextWriterTag get () override;
}
/** @property */
protected HtmlTextWriterTag get_TagKey ()

protected override function get TagKey () : HtmlTextWriterTag

Not applicable.

Property Value

An HtmlTextWriterTag enumeration value.

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

Use the TagKey property to determine the HtmlTextWriterTag value associated with an ImageButton control. This property overrides the base implementation to always return HtmlTextWriterTag.Input.

The following code example demonstrates how to override the TagKey method in a custom ImageButton control so that it always returns an Input tag.

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 the code sample must be copied into an empty text file that has an .aspx extension. The second part must be in a .cs file (for C#) or a .vb file (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" %>
<!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 ImageButton - TagKey - 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 - TagKey - VJ# Example</h3>
            
            <aspSample:CustomImageButtonTagKey 
              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 CustomImageButtonTagKey
    extends System.Web.UI.WebControls.ImageButton
{
    /** @property 
     */
    protected System.Web.UI.HtmlTextWriterTag get_TagKey()
    {
        // Specify that only the Input HTML tag can be passed to the 
        // HtmlTextWriter.
        return System.Web.UI.HtmlTextWriterTag.Input;
    } //get_TagKey
} //CustomImageButtonTagKey

Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show: