HtmlTextWriter.GetAttributeName(HtmlTextWriterAttribute) 方法

定義

取得與指定的 HtmlTextWriterAttribute 值相關聯的標記屬性名稱。

C#
protected string GetAttributeName (System.Web.UI.HtmlTextWriterAttribute attrKey);

參數

attrKey
HtmlTextWriterAttribute

要取得的標記屬性名稱之 HtmlTextWriterAttribute

傳回

String

字串,包含標記屬性的名稱。

範例

下列程式碼範例示範如何使用 GetAttributeName 方法,將列舉值轉換成 Size 其字串名稱。

C#
// Use the GetAttributeName method to associate 
// the Size attribute with its HtmlTextWriteAttribute
// enumeration value in a Write method call.
Write(GetAttributeName(HtmlTextWriterAttribute.Size));

備註

如果 attrKey 不是有效的 HtmlTextWriterAttribute 值,此方法 GetAttributeName 會傳回空字串 (「」「) 。

適用於

產品 版本
.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

另請參閱