TextBox.TagKey-Eigenschaft
Ruft das HTML-Tag für das Textfeld-Steuerelement ab. Diese Eigenschaft ist geschützt.
Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)
Syntax
'Declaration
Protected Overrides ReadOnly Property TagKey As HtmlTextWriterTag
'Usage
Dim value As HtmlTextWriterTag
value = Me.TagKey
protected override HtmlTextWriterTag TagKey { get; }
protected:
virtual property HtmlTextWriterTag TagKey {
HtmlTextWriterTag get () override;
}
/** @property */
protected HtmlTextWriterTag get_TagKey ()
protected override function get TagKey () : HtmlTextWriterTag
Eigenschaftenwert
HtmlTextWriterTag.Textarea, wenn das Textfeld mehrzeilig ist, andernfalls Input.
Beispiel
Im folgenden Codebeispiel wird veranschaulicht, wie mit der Tagkey-Eigenschaft ein benutzerdefiniertes Textfeld erstellt wird.
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.VB.Controls" Assembly="Samples.AspNet.VB" %>
<%@ Page Language="VB" AutoEventWireup="True" %>
<HTML>
<HEAD>
<title>Custom TextBox - TagKey - VB.NET Example</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<h3>Custom TextBox - TagKey - VB.NET Example</h3>
<aspSample:CustomTextBoxTagKey
id="TextBox1"
runat="server">Hello World!
</aspSample:CustomTextBoxTagKey>
</form>
</body>
</HTML>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.CS.Controls" Assembly="Samples.AspNet.CS" %>
<%@ Page Language="C#" AutoEventWireup="True" %>
<HTML>
<HEAD>
<title>Custom TextBox - TagKey - C# Example</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<h3>Custom TextBox - TagKey - C# Example</h3>
<aspSample:CustomTextBoxTagKey
id="TextBox1"
runat="server">Hello World!
</aspSample:CustomTextBoxTagKey>
</form>
</body>
</HTML>
<%@ Register TagPrefix="aspSample" Namespace="Samples.AspNet.JSL.Controls" Assembly="Samples.AspNet.JSL" %>
<%@ Page Language="VJ#" AutoEventWireup="True" %>
<HTML>
<HEAD>
<title>Custom TextBox - TagKey - VJ# Example</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<h3>Custom TextBox - TagKey - VJ# Example</h3>
<aspSample:CustomTextBoxTagKey
id="TextBox1"
runat="server"
text="Hello World!">
</aspSample:CustomTextBoxTagKey>
</form>
</body>
</HTML>
Imports System.Web
Imports System.Security.Permissions
Namespace Samples.AspNet.VB.Controls
<AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class CustomTextBoxTagKey
Inherits System.Web.UI.WebControls.TextBox
Protected Overrides ReadOnly Property TagKey() As System.Web.UI.HtmlTextWriterTag
Get
' If the TextMode is MultiLine, return a Textarea tag, else return an Input tag.
If Me.TextMode = System.Web.UI.WebControls.TextBoxMode.MultiLine Then
Return System.Web.UI.HtmlTextWriterTag.Textarea
Else
Return System.Web.UI.HtmlTextWriterTag.Input
End If
End Get
End Property
End Class
End Namespace
using System.Web;
using System.Security.Permissions;
namespace Samples.AspNet.CS.Controls
{
[AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Minimal)]
public sealed class CustomTextBoxTagKey : System.Web.UI.WebControls.TextBox
{
protected override System.Web.UI.HtmlTextWriterTag TagKey
{
get
{
// If the TextMode is MultiLine, return a Textarea tag,
// else return an Input tag.
if (this.TextMode == System.Web.UI.WebControls.TextBoxMode.MultiLine)
{
return System.Web.UI.HtmlTextWriterTag.Textarea;
}
else
{
return System.Web.UI.HtmlTextWriterTag.Input;
}
}
}
}
}
package Samples.AspNet.JSL.Controls;
public class CustomTextBoxTagKey
extends System.Web.UI.WebControls.TextBox
{
/** @property
*/
protected System.Web.UI.HtmlTextWriterTag get_TagKey()
{
// If the TextMode is MultiLine, return a Textarea tag,
// else return an Input tag.
if (this.get_TextMode().Equals(System.Web.UI.WebControls.
TextBoxMode.MultiLine)) {
return System.Web.UI.HtmlTextWriterTag.Textarea;
}
else {
return System.Web.UI.HtmlTextWriterTag.Input;
}
} //get_TagKey
} //CustomTextBoxTagKey
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
TextBox-Klasse
TextBox-Member
System.Web.UI.WebControls-Namespace