ImageButton.TagKey Özellik

Tanım

Denetime HtmlTextWriterTagImageButton karşılık gelen değeri alır.

protected:
 virtual property System::Web::UI::HtmlTextWriterTag TagKey { System::Web::UI::HtmlTextWriterTag get(); };
[System.ComponentModel.Browsable(false)]
protected override System.Web.UI.HtmlTextWriterTag TagKey { get; }
[<System.ComponentModel.Browsable(false)>]
member this.TagKey : System.Web.UI.HtmlTextWriterTag
Protected Overrides ReadOnly Property TagKey As HtmlTextWriterTag

Özellik Değeri

Bir HtmlTextWriterTag numaralandırma değeri.

Öznitelikler

Örnekler

Aşağıdaki kod örneği, her zaman bir Input etiketi döndürmesi için özel ImageButton bir denetimde yönteminin nasıl geçersiz kılındığını TagKey gösterir.

Not

Aşağıdaki kod örneği tek dosyalı kod modelini kullanır ve doğrudan arka planda kod dosyasına kopyalandığında düzgün çalışmayabilir. Kod örneğinin ilk bölümü.aspx uzantısına sahip boş bir metin dosyasına kopyalanmalıdır. İkinci bölüm bir .cs dosyasında (C#için) veya .vb dosyasında (Visual Basic için) olmalıdır. Web Forms kod modeli hakkında daha fazla bilgi için bkz. Sayfa Kodu Modeli ASP.NET Web Forms.

<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %>
<%@ Page Language="C#" 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 - C# Example</title>
    <script runat="server">
      void ImageButton1_Command(Object sender, CommandEventArgs e) 
      {
        // Redirect to the Microsoft home page.
        Response.Redirect("http://www.microsoft.com/");
      }
    </script>
    </head>
    <body>
        <form id="Form1" method="post" runat="server">
            <h3>Custom ImageButton - TagKey - C# 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>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %>
<%@ Page Language="VB" 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 - VB.NET Example</title>
        <script runat="server">
            Sub ImageButton1_Command(sender As Object, e As CommandEventArgs)
                ' Redirect to the Microsoft home page.
                Response.Redirect("http://www.microsoft.com/")
            End Sub
        </script>
    </head>
    <body>
        <form id="Form1" method="post" runat="server">
            <h3>Custom ImageButton - TagKey - VB.NET 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>
using System.Web;
using System.Security.Permissions;

namespace Samples.AspNet.CS.Controls
{
    [AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
    public sealed class CustomImageButtonTagKey : System.Web.UI.WebControls.ImageButton
    {
        protected override System.Web.UI.HtmlTextWriterTag TagKey
        {
            get
            {
            // Specify that only the Input HTML tag can be passed to the HtmlTextWriter.
            return System.Web.UI.HtmlTextWriterTag.Input;
            }
        }
    }
}
<AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class CustomImageButtonTagKey
    Inherits System.Web.UI.WebControls.ImageButton

    Protected Overrides ReadOnly Property TagKey() As System.Web.UI.HtmlTextWriterTag
        Get
            ' Specify that only the Input HTML tag can be passed to the HtmlTextWriter.
            Return System.Web.UI.HtmlTextWriterTag.Input
        End Get
    End Property
End Class

Açıklamalar

TagKey özelliği öncelikle denetim geliştiricileri tarafından denetimden ImageButton özel bir sınıf türetilirken kullanılır.

TagKey Bir denetimle ImageButton ilişkili değeri belirlemek HtmlTextWriterTag için özelliğini kullanın. Bu özellik, temel uygulamayı her zaman döndürecek HtmlTextWriterTag.Inputşekilde geçersiz kılar.

Şunlara uygulanır

Ayrıca bkz.