HtmlTextWriter.GetTagKey(String) 方法

定義

取得與指定標記項目相關聯的 HtmlTextWriterTag 列舉值。

C#
protected virtual System.Web.UI.HtmlTextWriterTag GetTagKey (string tagName);

參數

tagName
String

要取得的 HtmlTextWriterTag 之標記項目。

傳回

HtmlTextWriterTag

HtmlTextWriterTag 列舉值,否則,如果 tagName 未與特定的 HtmlTextWriterTag 值有關聯,則為 Unknown

範例

下列程式碼範例示範如何覆寫採用字串做為其參數之方法的多 RenderBeginTag 載。 字串會傳遞至 GetTagKey 方法,將它轉換成對應的 HtmlTextWriterTag 列舉成員,然後將它傳遞至 RenderBeginTag 採用 HtmlTextWriterTag 列舉值做為參數的多載。

C#
public override void RenderBeginTag(string tagName)
{
    // Call the overloaded RenderBeginTag(HtmlTextWriterTag)
    // method.
    RenderBeginTag(GetTagKey(tagName));
}

備註

如果 tagNamenull ,則空字串 (「」「) ,或在標記標記名稱的資料表中找不到, GetTagKey 則方法會 Unknown 傳回 欄位。

適用於

產品 版本
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8

另請參閱