ImageButton.TagKey プロパティ
アセンブリ: System.Web (system.web.dll 内)

HtmlTextWriterTag 列挙値。

TagKey プロパティは、カスタム クラスを ImageButton コントロールから派生させる場合に、主に開発者によって使用されます。
TagKey プロパティを使用して、ImageButton コントロールに関連付けられた HtmlTextWriterTag 値を確認します。このプロパティは基本実装をオーバーライドし、常に HtmlTextWriterTag.Input が返されるようにします。

カスタムの ImageButton コントロールの TagKey メソッドをオーバーライドして、常に Input タグが返されるようにする方法のコード例を次に示します。
![]() |
---|
次のコード サンプルはシングルファイル コード モデルを使用しており、分離コード ファイルに直接コピーされた場合は正常に動作しない可能性があります。このコード サンプルの最初の部分は、拡張子が .aspx の空のテキスト ファイルにコピーする必要があります。2 番目の部分は .cs ファイル (C# の場合) または .vb ファイル (Visual Basic の場合) に入れる必要があります。Web フォームのコード モデルの詳細については、「ASP.NET Web ページのコード モデル」を参照してください。 |
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %> <%@ Page Language="VB" AutoEventWireup="True" %> <HTML> <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> <br /><span space="preserve">...</span><br /> <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
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %> <%@ Page Language="C#" AutoEventWireup="True" %> <HTML> <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> <br /><span space="preserve">...</span><br />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; } } } }
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSL.Controls" Assembly="Samples.AspNet.JSL" %> <%@ Page Language="VJ#" AutoEventWireup="True" %> <HTML> <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> <br /><span space="preserve">...</span><br />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 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からImageButton.TagKey プロパティを検索する場合は、下記のリンクをクリックしてください。

- ImageButton.TagKey プロパティのページへのリンク