TagBuilder Class

Definition

Contains methods and properties that are used to create HTML elements. This class is often used to write HTML helpers and tag helpers.

public ref class TagBuilder : Microsoft::AspNetCore::Html::IHtmlContent
public class TagBuilder : Microsoft.AspNetCore.Html.IHtmlContent
type TagBuilder = class
    interface IHtmlContent
Public Class TagBuilder
Implements IHtmlContent
Inheritance
TagBuilder
Implements

Constructors

TagBuilder(String)

Creates a new HTML tag that has the specified tag name.

Properties

Attributes

Gets the set of attributes that will be written to the tag.

HasInnerHtml

Gets an indication InnerHtml is not empty.

InnerHtml

Gets the inner HTML content of the element.

TagName

Gets the tag name for this tag.

TagRenderMode

The TagRenderMode with which the tag is written.

Methods

AddCssClass(String)

Adds a CSS class to the list of CSS classes in the tag. If there are already CSS classes on the tag then a space character and the new class will be appended to the existing list.

CreateSanitizedId(String, String)

Returns a valid HTML 4.01 "id" attribute value for an element with the given name.

GenerateId(String, String)

Adds a valid HTML 4.01 "id" attribute for an element with the given name. Does nothing if Attributes already contains an "id" attribute or the name is null or empty.

MergeAttribute(String, String)
MergeAttribute(String, String, Boolean)
MergeAttributes<TKey,TValue>(IDictionary<TKey,TValue>)
MergeAttributes<TKey,TValue>(IDictionary<TKey,TValue>, Boolean)
RenderBody()

Returns an IHtmlContent that renders the body.

RenderEndTag()

Returns an IHtmlContent that renders the end tag.

RenderSelfClosingTag()

Returns an IHtmlContent that renders the self-closing tag.

RenderStartTag()

Returns an IHtmlContent that renders the start tag.

WriteTo(TextWriter, HtmlEncoder)

Applies to