TagBuilder TagBuilder 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.

public class TagBuilder
type TagBuilder = class
Public Class TagBuilder


TagBuilder(String) TagBuilder(String) TagBuilder(String)

Creates a new tag that has the specified tag name.


Attributes Attributes Attributes

Gets the collection of attributes.

IdAttributeDotReplacement IdAttributeDotReplacement IdAttributeDotReplacement

Gets or sets a string that can be used to replace invalid HTML characters.

InnerHtml InnerHtml InnerHtml

Gets or sets the inner HTML value for the element.

TagName TagName TagName

Gets the tag name for this tag.


AddCssClass(String) AddCssClass(String) AddCssClass(String)

Adds a CSS class to the list of CSS classes in the tag.

CreateSanitizedId(String) CreateSanitizedId(String) CreateSanitizedId(String)

Replaces each invalid character in the tag ID with a valid HTML character.

CreateSanitizedId(String, String) CreateSanitizedId(String, String) CreateSanitizedId(String, String)

Replaces each invalid character in the tag ID with the specified replacement string.

GenerateId(String) GenerateId(String) GenerateId(String)

Generates a sanitized ID attribute for the tag by using the specified name.

MergeAttribute(String, String) MergeAttribute(String, String) MergeAttribute(String, String)

Adds a new attribute to the tag.

MergeAttribute(String, String, Boolean) MergeAttribute(String, String, Boolean) MergeAttribute(String, String, Boolean)

Adds a new attribute or optionally replaces an existing attribute in the opening tag.

MergeAttributes<TKey,TValue>(IDictionary<TKey,TValue>) MergeAttributes<TKey,TValue>(IDictionary<TKey,TValue>) MergeAttributes<TKey,TValue>(IDictionary<TKey,TValue>)

Adds new attributes to the tag.

MergeAttributes<TKey,TValue>(IDictionary<TKey,TValue>, Boolean) MergeAttributes<TKey,TValue>(IDictionary<TKey,TValue>, Boolean) MergeAttributes<TKey,TValue>(IDictionary<TKey,TValue>, Boolean)

Adds new attributes or optionally replaces existing attributes in the tag.

SetInnerText(String) SetInnerText(String) SetInnerText(String)

Sets the InnerHtml property of the element to an HTML-encoded version of the specified string.

ToString() ToString() ToString()

Renders the element as a Normal element.

ToString(TagRenderMode) ToString(TagRenderMode) ToString(TagRenderMode)

Renders the HTML tag by using the specified render mode.

Applies to