Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

TagBuilder Class

Contains classes and properties that are used to create HTML elements. This class is used to write helpers, such as those found in the System.Web.Helpers namespace.


Namespace:  System.Web.Mvc
Assembly:  System.Web.WebPages (in System.Web.WebPages.dll)

public class TagBuilder

The TagBuilder type exposes the following members.

Public methodTagBuilderCreates a new tag that has the specified tag name.

Public propertyAttributesGets the collection of attributes.
Public propertyIdAttributeDotReplacementGets or sets a string that can be used to replace invalid HTML characters.
Public propertyInnerHtmlGets or sets the inner HTML value for the element.
Public propertyTagNameGets the tag name for this tag.

Public methodAddCssClassAdds a CSS class to the list of CSS classes in the tag.
Public methodStatic memberCreateSanitizedId(String)Replaces each invalid character in the tag ID with a valid HTML character.
Public methodStatic memberCreateSanitizedId(String, String)Replaces each invalid character in the tag ID with the specified replacement string.
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGenerateIdGenerates a sanitized ID attribute for the tag by using the specified name.
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodMergeAttribute(String, String)Adds a new attribute to the tag.
Public methodMergeAttribute(String, String, Boolean)Adds a new attribute or optionally replaces an existing attribute in the opening tag.
Public methodMergeAttributes<TKey, TValue>(IDictionary<TKey, TValue>)Adds new attributes to the tag.
Public methodMergeAttributes<TKey, TValue>(IDictionary<TKey, TValue>, Boolean)Adds new attributes or optionally replaces existing attributes in the tag.
Public methodSetInnerTextSets the InnerHtml property of the element to an HTML-encoded version of the specified string.
Public methodToString()Renders the element as a Normal element. (Overrides Object.ToString().)
Public methodToString(TagRenderMode)Renders the HTML tag by using the specified render mode.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
© 2018 Microsoft