This documentation is archived and is not being maintained.

HtmlControl.TagName Property

Gets the element name of a tag that contains a runat=server attribute and value pair.

[Visual Basic]
Public Overridable ReadOnly Property TagName As String
[C#]
public virtual string TagName {get;}
[C++]
public: __property virtual String* get_TagName();
[JScript]
public function get TagName() : String;

Property Value

The element name of the specified tag.

Remarks

Use this property to programmatically determine the element name of the HTML server control. For example, the TagName property of the server-side <div id="myDiv" runat=server> element contains the value "div".

Example

[Visual Basic, C#, JScript] The following example demonstrates how to use the TagName property to programmatically determine the element name of a tag.

[Visual Basic] 
<%@ Page Language="VB" AutoEventWireup="True" %>

<html>
<head>
   <script language="VB" runat=server>
    Sub Submit_Clicked(sender As Object, e As EventArgs)
        
        Message.InnerHtml = "My TagName is: " & Submit1.TagName
    End Sub 'Submit_Clicked 
  </script>
</head>
 
<body>
   <form method=post runat=server>

      <h3>HtmlControl TagName Property Example</h3>

      <input id="Submit1"        
             type="submit"
             value="Click Me!!"
             OnServerClick="Submit_Clicked"
             runat="server"/>
      
      <br><br>

      <span id="Message" runat="server"/>  
 
   </form>

</body>
</html>


[C#] 
<%@ Page Language="C#" AutoEventWireup="True" %>

<html>
<head>
   <script language="C#" runat=server>
 
      void Submit_Clicked(Object sender, EventArgs e) 
      {
         
         Message.InnerHtml = "My TagName is: " + Submit1.TagName;
 
      }        
      
 
   </script>
</head>
 
<body>
   <form method=post runat=server>

      <h3>HtmlControl TagName Property Example</h3>

      <input id="Submit1"        
             type="submit"
             value="Click Me!!"
             OnServerClick="Submit_Clicked"
             runat="server"/>
      
      <br><br>

      <span id="Message" runat="server"/>  
 
   </form>

</body>
</html>


[JScript] 
<%@ Page Language="JScript" AutoEventWireup="True" %>

<html>
<head>
   <script language="jscript" runat=server>
    function Submit_Clicked(sender: Object, e: EventArgs){
        Message.InnerHtml = "My TagName is: " + Submit1.TagName
    }
  </script>
</head>
 
<body>
   <form method=post runat=server>

      <h3>HtmlControl TagName Property Example</h3>

      <input id="Submit1"        
             type="submit"
             value="Click Me!!"
             OnServerClick="Submit_Clicked"
             runat="server"/>
      
      <br><br>

      <span id="Message" runat="server"/>  
 
   </form>

</body>
</html>

[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

HtmlControl Class | HtmlControl Members | System.Web.UI.HtmlControls Namespace

Show: