HtmlTextWriter.GetTagKey(String) Method

Definition

Obtains the HtmlTextWriterTag enumeration value associated with the specified markup element.

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

Parameters

tagName
String

The markup element for which to obtain the HtmlTextWriterTag.

Returns

The HtmlTextWriterTag enumeration value; otherwise, if tagName is not associated with a specific HtmlTextWriterTag value, Unknown.

Examples

The following code example shows how to override the overload of the RenderBeginTag method that takes a string as its parameter. The string is passed to the GetTagKey method, which converts it to the corresponding HtmlTextWriterTag enumeration member, and then passes that to the RenderBeginTag overload that takes a HtmlTextWriterTag enumeration value as a parameter.

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

Remarks

If tagName is null, an empty string (""), or cannot be found in the table of markup tag names, the GetTagKey method returns the Unknown field.

Applies to

Product Versions
.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, 4.8.1

See also