System.Web.UI.HtmlControls Namespace HtmlGenericControl Class
Sets or retrieves the tag name of an element that contains a runat="server" attribute.
Script |
HtmlGenericControl.TagName = strTagName ] |
This property can only be used programmatically; it cannot be set when declaring the control.
strTagName |
String that represents an HTML element name. |
The property is read/write with no default value.
Use this property to dynamically change the tag name of a generic control on the Web page.
For a <span id="mySpan" runat="server"/>
tag, this property would return a value of span.
The below code shows how to use the TagName property to programmatically change a tag name from Body to Font and back.
<script language="C#" runat="server">
void chgBodyColor ( object src, EventArgs e ) {
Body.Attributes [ "bgcolor" ] = colorSelect.Value;
}
void chgFontColor ( object src, EventArgs e ) {
Body.TagName="Font";
Body.Attributes [ "Color" ] = colorSelect.Value;
}
</script>
<script language="VB" runat="server">
Sub chgBodyColor ( sender As Object, e As EventArgs )
Body.Attributes ( "bgcolor" ) = colorSelect.Value
End Sub
Sub chgFontColor ( sender As Object, e As EventArgs )
Body.TagName = "Font"
Body.Attributes ( "Color" ) = colorSelect.Value
End Sub
</script>
<script language="JSCRIPT" runat="server">
function chgBodyColor ( sender : Object, e : EventArgs ) {
Body.Attributes [ "bgcolor" ] = colorSelect.Value
}
function chgFontColor ( sender : Object, e : EventArgs ) {
Body.TagName = "Font"
Body.Attributes [ "Color" ] = colorSelect.Value
}
</script> |
|
C# |
VB |
JScript |
Show me
HtmlGenericControl Members