TagBuilder Class

Syntax

public class TagBuilder

GitHub

View on GitHub

class Microsoft.AspNet.Mvc.Rendering.TagBuilder

Constructors

TagBuilder(System.String)
Arguments:
  • tagName (System.String) –
public TagBuilder(string tagName)
TagBuilder(System.String, IHtmlEncoder)
Arguments:
  • tagName (System.String) –
  • htmlEncoder (IHtmlEncoder) –
public TagBuilder(string tagName, IHtmlEncoder htmlEncoder)

Properties

Attributes()
Return type:System.Collections.Generic.IDictionary{System.String,System.String}
public IDictionary<string, string> Attributes { get; }
InnerHtml()
Return type:System.String
public string InnerHtml { get; set; }
TagName()
Return type:System.String
public string TagName { get; }

Methods

AddCssClass(System.String)
Arguments:
  • value (System.String) –
public void AddCssClass(string value)
CreateSanitizedId(System.String, System.String)

Return valid HTML 4.01 “id” attribute for an element with the given <paramref name=”name” />.

Arguments:
  • name (System.String) – The original element name.
  • invalidCharReplacement (System.String) – The [System.String]() (normally a single [System.Char]()) to substitute for invalid characters in <paramref name=”name” />.
Return type:

System.String

Returns:

Valid HTML 4.01 “id” attribute for an element with the given <paramref name=”name” />.

public static string CreateSanitizedId(string name, string invalidCharReplacement)
GenerateId(System.String, System.String)
Arguments:
  • name (System.String) –
  • idAttributeDotReplacement (System.String) –
public void GenerateId(string name, string idAttributeDotReplacement)
MergeAttribute(System.String, System.String)
Arguments:
  • key (System.String) –
  • value (System.String) –
public void MergeAttribute(string key, string value)
MergeAttribute(System.String, System.String, System.Boolean)
Arguments:
  • key (System.String) –
  • value (System.String) –
  • replaceExisting (System.Boolean) –
public void MergeAttribute(string key, string value, bool replaceExisting)
Microsoft.AspNet.Mvc.Rendering.TagBuilder.MergeAttributes<TKey, TValue>(System.Collections.Generic.IDictionary<TKey, TValue>)
Arguments:
  • attributes (System.Collections.Generic.IDictionary{{TKey},{TValue}}) –
public void MergeAttributes<TKey, TValue>(IDictionary<TKey, TValue> attributes)
Microsoft.AspNet.Mvc.Rendering.TagBuilder.MergeAttributes<TKey, TValue>(System.Collections.Generic.IDictionary<TKey, TValue>, System.Boolean)
Arguments:
  • attributes (System.Collections.Generic.IDictionary{{TKey},{TValue}}) –
  • replaceExisting (System.Boolean) –
public void MergeAttributes<TKey, TValue>(IDictionary<TKey, TValue> attributes, bool replaceExisting)
SetInnerText(System.String)
Arguments:
  • innerText (System.String) –
public void SetInnerText(string innerText)
ToHtmlString(Microsoft.AspNet.Mvc.Rendering.TagRenderMode)
Arguments:
Return type:

Microsoft.AspNet.Mvc.Rendering.HtmlString

public HtmlString ToHtmlString(TagRenderMode renderMode)
Microsoft.AspNet.Mvc.Rendering.TagBuilder.ToString()
Return type:System.String
public override string ToString()
ToString(Microsoft.AspNet.Mvc.Rendering.TagRenderMode)
Arguments:
Return type:

System.String

public string ToString(TagRenderMode renderMode)