Share via


TagBuilder Class

Definition

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

Constructors

TagBuilder(String)

Creates a new tag that has the specified tag name.

Properties

Attributes

Gets the collection of attributes.

IdAttributeDotReplacement

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

InnerHtml

Gets or sets the inner HTML value for the element.

TagName

Gets the tag name for this tag.

Methods

AddCssClass(String)

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

CreateSanitizedId(String, String)

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

CreateSanitizedId(String)

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

GenerateId(String)

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

MergeAttribute(String, String, Boolean)

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

MergeAttribute(String, String)

Adds a new attribute to the tag.

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

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

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

Adds new attributes to the tag.

SetInnerText(String)

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

ToString()

Renders the element as a Normal element.

ToString(TagRenderMode)

Renders the HTML tag by using the specified render mode.

Applies to