HtmlTextWriter.GetTagKey(String) 方法     
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取与指定标记元素关联的 HtmlTextWriterTag 枚举值。
protected:
 virtual System::Web::UI::HtmlTextWriterTag GetTagKey(System::String ^ tagName);protected virtual System.Web.UI.HtmlTextWriterTag GetTagKey (string tagName);abstract member GetTagKey : string -> System.Web.UI.HtmlTextWriterTag
override this.GetTagKey : string -> System.Web.UI.HtmlTextWriterTagProtected Overridable Function GetTagKey (tagName As String) As HtmlTextWriterTag参数
- tagName
- String
要为其获取 HtmlTextWriterTag 的标记元素。
返回
HtmlTextWriterTag 枚举值;否则,如果 tagName 不与特定的 HtmlTextWriterTag 值关联,则为 Unknown。
示例
下面的代码示例演示如何重写采用字符串作为其参数的方法的 RenderBeginTag 重载。 字符串将传递给 GetTagKey 方法,该方法将其转换为相应的 HtmlTextWriterTag 枚举成员,然后将该 RenderBeginTag 字符串传递给将枚举值作为参数的重载 HtmlTextWriterTag 。
virtual void RenderBeginTag( String^ tagName ) override
{
   
   // Call the overloaded RenderBeginTag(HtmlTextWriterTag) method.
   RenderBeginTag( GetTagKey( tagName ) );
}
public override void RenderBeginTag(string tagName)
{
    // Call the overloaded RenderBeginTag(HtmlTextWriterTag)
    // method.
    RenderBeginTag(GetTagKey(tagName));
}
Public Overloads Overrides Sub RenderBeginTag(ByVal tagName As String)
    ' Call the overloaded RenderBeginTag(HtmlTextWriterTag) method.
    RenderBeginTag(GetTagKey(tagName))
End Sub
注解
如果 tagName 为 null空字符串 (“”) ,或者无法在标记标记名称表中找到,该方法 GetTagKey 将 Unknown 返回该字段。