TextBox.TagKey Property
.NET Framework 3.0
Gets the HTML tag for the text box control. This property is protected.
Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)
Assembly: System.Web (in system.web.dll)
/** @property */ protected HtmlTextWriterTag get_TagKey ()
protected override function get TagKey () : HtmlTextWriterTag
Not applicable.
Property Value
HtmlTextWriterTag.Textarea if the text box is multiline; otherwise, Input.The following code example demonstrates how to use the Tagkey property to create a custom text box.
Security Note: |
|---|
| This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview (Visual Studio). |
<%@ 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 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>
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
Community Additions
ADD
Show:
Security Note: