Aracılığıyla paylaş


HtmlGenericControl.TagName Özellik

Tanım

Denetim tarafından HtmlGenericControl temsil edilen HTML öğesinin adını alır veya ayarlar.

public:
 property System::String ^ TagName { System::String ^ get(); void set(System::String ^ value); };
public string TagName { get; set; }
member this.TagName : string with get, set
Public Property TagName As String

Özellik Değeri

String

Öğenin etiket adı.

Örnekler

Aşağıdaki kod örneği, bir etiket adını program aracılığıyla "Gövde" olan "Yazı Tipi" ve geri değiştirmek için özelliğinin nasıl kullanılacağını TagName gösterir.

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

  protected void BG_Button_Click(object sender, EventArgs e)
  {
    Body.Attributes["bgcolor"] = ColorSelect.Value;
  }

  protected void Font_Button_Click(object sender, EventArgs e)
  {
    Body.TagName = "Font";
    Body.Attributes["Color"] = ColorSelect.Value;
  }
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
  <title>HtmlGenericControl Example</title> 
</head>
 
 <body id="Body" 
       runat="server"> 

     <h3>HtmlGenericControl Example</h3>

     <form id="form1" runat="server">
     <div>
       <br />
       Select a background color for the page: <br />
       <select id="ColorSelect" 
               runat="server">
           <option>White</option>
           <option>LightBlue</option>
           <option>LightGreen</option>
           <option>Yellow</option>
       </select>
       <br />
       <input type="submit" 
              runat="server"
              value="Change Background Color" 
              onserverclick="BG_Button_Click" id="Submit1" />
       <input type="submit" 
              runat="server" 
              value="Change Font Color" 
              onserverclick="Font_Button_Click" id="Submit2" />
     </div>
     </form>
 
 </body>
 </html>
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
  
  Protected Sub BG_Button_Click(ByVal sender As Object, ByVal e As System.EventArgs)

    Body.Attributes("bgcolor") = ColorSelect.Value

  End Sub

  Protected Sub Font_Button_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    
    Body.TagName = "Font"
    Body.Attributes("Color") = ColorSelect.Value

  End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
  <title>HtmlGenericControl Example</title> 
</head>
 
 <body id="Body" 
       runat="server"> 

     <h3>HtmlGenericControl Example</h3>

     <form id="form1" runat="server">
     <div> 
       <br />
       Select a background color for the page: <br />
       <select id="ColorSelect" 
               runat="server">
           <option>White</option>
           <option>LightBlue</option>
           <option>LightGreen</option>
           <option>Yellow</option>
       </select>
       <br />
       <input type="submit" 
              runat="server"
              value="Change Background Color" 
              onserverclick="BG_Button_Click" id="Submit1" />
       <input type="submit" 
              runat="server" 
              value="Change Font Color" 
              onserverclick="Font_Button_Click" id="Submit2" />
     </div>
     </form>
 
 </body>
 </html>

Açıklamalar

HTML sunucu denetiminin öğe adını program aracılığıyla belirlemek için bu özelliği kullanın. Örneğin, sunucu tarafı <span id="MySpan" runat= "server"/> öğesinin TagName özelliği "span" değerini içerir.

Şunlara uygulanır