IHtmlHelper Interface

Summary

Base HTML helpers.

Syntax

public interface IHtmlHelper

GitHub

View on GitHub

interface Microsoft.AspNet.Mvc.Rendering.IHtmlHelper

Properties

Html5DateRenderingMode()

Set this property to [Microsoft.AspNet.Mvc.Rendering.Html5DateRenderingMode.Rfc3339](Microsoft.AspNet.Mvc.Rendering.Html5DateRenderingMode.yml) to have templated helpers such as [Microsoft.AspNet.Mvc.Rendering.IHtmlHelper.Editor(System.String,System.String,System.String,System.Object)](Microsoft.AspNet.Mvc.Rendering.IHtmlHelper.yml) and [Microsoft.AspNet.Mvc.Rendering.IHtmlHelper`1.EditorFor``1(System.Linq.Expressions.Expression{System.Func{`0,``0}},System.String,System.String,System.Object)](Microsoft.AspNet.Mvc.Rendering.IHtmlHelper`1.yml) render date and time values as RFC 3339 compliant strings. By default these helpers render dates and times using the current culture.

Return type:Microsoft.AspNet.Mvc.Rendering.Html5DateRenderingMode
Html5DateRenderingMode Html5DateRenderingMode { get; set; }
HtmlEncoder()

Gets the @!:IHtmlEncoder- to be used for encoding HTML.

Return type:IHtmlEncoder
IHtmlEncoder HtmlEncoder { get; }
IdAttributeDotReplacement()

Gets the [System.String]() that replaces periods in the ID attribute of an element.

Return type:System.String
string IdAttributeDotReplacement { get; }
JavaScriptStringEncoder()

Gets the @!:IJavaScriptStringEncoder- to be used for encoding JavaScript.

Return type:IJavaScriptStringEncoder
IJavaScriptStringEncoder JavaScriptStringEncoder { get; }
MetadataProvider()

Gets the metadata provider. Intended for use in [Microsoft.AspNet.Mvc.Rendering.IHtmlHelper](Microsoft.AspNet.Mvc.Rendering.IHtmlHelper.yml) extension methods.

Return type:Microsoft.AspNet.Mvc.ModelBinding.IModelMetadataProvider
IModelMetadataProvider MetadataProvider { get; }
TempData()

Gets the current [Microsoft.AspNet.Mvc.ITempDataDictionary]() instance.

Return type:Microsoft.AspNet.Mvc.ITempDataDictionary
ITempDataDictionary TempData { get; }
UrlEncoder()

Gets the @!:IUrlEncoder- to be used for encoding a URL.

Return type:IUrlEncoder
IUrlEncoder UrlEncoder { get; }
ViewBag()

Gets the view bag.

Return type:dynamic
ViewBag { get; }
ViewContext()

Gets the context information about the view.

Return type:Microsoft.AspNet.Mvc.ViewContext
ViewContext ViewContext { get; }
ViewData()

Gets the current view data.

Return type:Microsoft.AspNet.Mvc.ViewDataDictionary
ViewDataDictionary ViewData { get; }

Methods

Returns an anchor (<a>) element that contains a URL path to the specified action.

Arguments:
  • linkText (System.String) – The inner text of the anchor element. Must not be <c>null</c>.
  • actionName (System.String) – The name of the action.
  • controllerName (System.String) – The name of the controller.
  • protocol (System.String) – The protocol for the URL, such as “http” or “https”.
  • hostname (System.String) – The host name for the URL.
  • fragment (System.String) – The URL fragment name (the anchor name).
  • routeValues (System.Object) – An [System.Object]() that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the [System.Object](). This [System.Object]() is typically created using [System.Object]() initializer syntax. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the route parameters.
  • htmlAttributes (System.Object) – An [System.Object]() that contains the HTML attributes for the element. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the HTML attributes.
Return type:

Microsoft.AspNet.Mvc.Rendering.HtmlString

Returns:

A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the anchor element.

HtmlString ActionLink(string linkText, string actionName, string controllerName, string protocol, string hostname, string fragment, object routeValues, object htmlAttributes)
Microsoft.AspNet.Mvc.Rendering.IHtmlHelper.AntiForgeryToken()

Returns a &lt;hidden&gt; element (anti-forgery token) that will be validated when the containing &lt;form&gt; is submitted.

Return type:Microsoft.AspNet.Mvc.Rendering.HtmlString
Returns:A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the &lt;hidden&gt; element.
HtmlString AntiForgeryToken()
BeginForm(System.String, System.String, System.Object, Microsoft.AspNet.Mvc.Rendering.FormMethod, System.Object)

Renders a &lt;form&gt; start tag to the response. When the user submits the form, the action with name

<paramref name=”actionName” /> will process the request.

Arguments:
  • actionName (System.String) – The name of the action method.
  • controllerName (System.String) – The name of the controller.
  • routeValues (System.Object) – An [System.Object]() that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the [System.Object](). This [System.Object]() is typically created using [System.Object]() initializer syntax. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the route parameters.
  • method (Microsoft.AspNet.Mvc.Rendering.FormMethod) – The HTTP method for processing the form, either GET or POST.
  • htmlAttributes (System.Object) – An [System.Object]() that contains the HTML attributes for the element. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the HTML attributes.
Return type:

Microsoft.AspNet.Mvc.Rendering.MvcForm

Returns:

An [Microsoft.AspNet.Mvc.Rendering.MvcForm](Microsoft.AspNet.Mvc.Rendering.MvcForm.yml) instance which renders the &lt;/form&gt; end tag when disposed.

MvcForm BeginForm(string actionName, string controllerName, object routeValues, FormMethod method, object htmlAttributes)
BeginRouteForm(System.String, System.Object, Microsoft.AspNet.Mvc.Rendering.FormMethod, System.Object)

Renders a &lt;form&gt; start tag to the response. The route with name <paramref name=”routeName” /> generates the &lt;form&gt;’s <c>action</c> attribute value.

Arguments:
  • routeName (System.String) – The name of the route.
  • routeValues (System.Object) – An [System.Object]() that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the [System.Object](). This [System.Object]() is typically created using [System.Object]() initializer syntax. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the route parameters.
  • method (Microsoft.AspNet.Mvc.Rendering.FormMethod) – The HTTP method for processing the form, either GET or POST.
  • htmlAttributes (System.Object) – An [System.Object]() that contains the HTML attributes for the element. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the HTML attributes.
Return type:

Microsoft.AspNet.Mvc.Rendering.MvcForm

Returns:

An [Microsoft.AspNet.Mvc.Rendering.MvcForm](Microsoft.AspNet.Mvc.Rendering.MvcForm.yml) instance which renders the &lt;/form&gt; end tag when disposed.

MvcForm BeginRouteForm(string routeName, object routeValues, FormMethod method, object htmlAttributes)
CheckBox(System.String, System.Nullable<System.Boolean>, System.Object)

Returns an &lt;input&gt; element of type “checkbox” with value “true” and an &lt;input&gt; element of type “hidden” with value “false”.

Arguments:
  • expression (System.String) – Expression name, relative to the current model.
  • isChecked (System.Nullable{System.Boolean}) – If <c>true</c>, checkbox is initially checked.
  • htmlAttributes (System.Object) – An [System.Object]() that contains the HTML attributes for the checkbox element. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the HTML attributes.
Return type:

Microsoft.AspNet.Mvc.Rendering.HtmlString

Returns:

A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the &lt;input&gt; elements.

HtmlString CheckBox(string expression, bool ? isChecked, object htmlAttributes)
Display(System.String, System.String, System.String, System.Object)

Returns HTML markup for the <paramref name=”expression” />, using a display template, specified HTML field name, and additional view data. The template is found using the <paramref name=”templateName” /> or the

<paramref name=”expression” />’s [Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata]().

Arguments:
  • expression (System.String) – Expression name, relative to the current model. May identify a single property or an [System.Object]() that contains the properties to display.
  • templateName (System.String) – The name of the template used to create the HTML markup.
  • htmlFieldName (System.String) – A [System.String]() used to disambiguate the names of HTML elements that are created for properties that have the same name.
  • additionalViewData (System.Object) – An anonymous [System.Object]() or [System.Collections.Generic.IDictionary`2]() that can contain additional view data that will be merged into the [Microsoft.AspNet.Mvc.ViewDataDictionary`1](Microsoft.AspNet.Mvc.ViewDataDictionary`1.yml) instance created for the template.
Return type:

Microsoft.AspNet.Mvc.Rendering.HtmlString

Returns:

A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the created HTML.

HtmlString Display(string expression, string templateName, string htmlFieldName, object additionalViewData)
DisplayName(System.String)

Returns the display name for the specified <paramref name=”expression” />.

Arguments:
  • expression (System.String) – Expression name, relative to the current model.
Return type:

System.String

Returns:

A [System.String]() containing the display name.

string DisplayName(string expression)
DisplayText(System.String)

Returns the simple display text for the specified <paramref name=”expression” />.

Arguments:
  • expression (System.String) – Expression name, relative to the current model.
Return type:

System.String

Returns:

A [System.String]() containing the simple display text. If the expression result is <c>null</c>, returns [Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata.NullDisplayText]().

string DisplayText(string expression)
DropDownList(System.String, System.Collections.Generic.IEnumerable<Microsoft.AspNet.Mvc.Rendering.SelectListItem>, System.String, System.Object)

Returns a single-selection HTML &lt;select&gt; element for the <paramref name=”expression” />, using the specified list items, option label, and HTML attributes.

Arguments:
  • expression (System.String) – Expression name, relative to the current model.
  • selectList (System.Collections.Generic.IEnumerable{Microsoft.AspNet.Mvc.Rendering.SelectListItem}) – A collection of [Microsoft.AspNet.Mvc.Rendering.SelectListItem](Microsoft.AspNet.Mvc.Rendering.SelectListItem.yml) objects used to populate the &lt;select&gt; element with &lt;optgroup&gt; and &lt;option&gt; elements.
  • optionLabel (System.String) – The text for a default empty item. Does not include such an item if argument is <c>null</c>.
  • htmlAttributes (System.Object) – An [System.Object]() that contains the HTML attributes for the &lt;select&gt; element. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the HTML attributes.
Return type:

Microsoft.AspNet.Mvc.Rendering.HtmlString

Returns:

A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the &lt;select&gt; element.

HtmlString DropDownList(string expression, IEnumerable<SelectListItem> selectList, string optionLabel, object htmlAttributes)
Editor(System.String, System.String, System.String, System.Object)

Returns HTML markup for the <paramref name=”expression” />, using an editor template, specified HTML field name, and additional view data. The template is found using the <paramref name=”templateName” /> or the

<paramref name=”expression” />’s [Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata]().

Arguments:
  • expression (System.String) – Expression name, relative to the current model. May identify a single property or an [System.Object]() that contains the properties to edit.
  • templateName (System.String) – The name of the template used to create the HTML markup.
  • htmlFieldName (System.String) – A [System.String]() used to disambiguate the names of HTML elements that are created for properties that have the same name.
  • additionalViewData (System.Object) – An anonymous [System.Object]() or [System.Collections.Generic.IDictionary`2]() that can contain additional view data that will be merged into the [Microsoft.AspNet.Mvc.ViewDataDictionary`1](Microsoft.AspNet.Mvc.ViewDataDictionary`1.yml) instance created for the template.
Return type:

Microsoft.AspNet.Mvc.Rendering.HtmlString

Returns:

A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the &lt;input&gt; element(s).

HtmlString Editor(string expression, string templateName, string htmlFieldName, object additionalViewData)
Encode(System.Object)

Converts the <paramref name=”value” /> to an HTML-encoded [System.String]().

Arguments:
  • value (System.Object) – The [System.Object]() to encode.
Return type:

System.String

Returns:

The HTML-encoded [System.String]().

string Encode(object value)
Encode(System.String)

Converts the specified [System.String]() to an HTML-encoded [System.String]().

Arguments:
  • value (System.String) – The [System.String]() to encode.
Return type:

System.String

Returns:

The HTML-encoded [System.String]().

string Encode(string value)
Microsoft.AspNet.Mvc.Rendering.IHtmlHelper.EndForm()

Renders the &lt;/form&gt; end tag to the response.

void EndForm()
FormatValue(System.Object, System.String)

Formats the value.

Arguments:
Return type:

System.String

Returns:

A [System.String]() containing the formatted value.

string FormatValue(object value, string format)
GenerateIdFromName(System.String)

Returns an HTML element Id for the specified expression <paramref name=”fullName” />.

Arguments:
  • fullName (System.String) – Fully-qualified expression name, ignoring the current model. Must not be <c>null</c>.
Return type:

System.String

Returns:

A [System.String]() containing the element Id.

string GenerateIdFromName(string fullName)
GetClientValidationRules(Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer, System.String)

Returns information about about client validation rules for the specified <paramref name=”metadata” /> or

<paramref name=”expression” />. Intended for use in [Microsoft.AspNet.Mvc.Rendering.IHtmlHelper](Microsoft.AspNet.Mvc.Rendering.IHtmlHelper.yml) extension methods.

Arguments:
  • modelExplorer (Microsoft.AspNet.Mvc.ModelBinding.ModelExplorer) –
  • expression (System.String) – Expression name, relative to the current model. Used to determine [Microsoft.AspNet.Mvc.ModelBinding.ModelMetadata]() when <paramref name=”metadata” /> is <c>null</c>; ignored otherwise.
Return type:

System.Collections.Generic.IEnumerable{Microsoft.AspNet.Mvc.ModelBinding.Validation.ModelClientValidationRule}

Returns:

An [System.Collections.Generic.IEnumerable`1]() containing the relevant rules.

IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelExplorer modelExplorer, string expression)
GetEnumSelectList(System.Type)

Returns a select list for the given <paramref name=”enumType” />.

Arguments:
  • enumType (System.Type) – [System.Type]() to generate a select list for.
Return type:

System.Collections.Generic.IEnumerable{Microsoft.AspNet.Mvc.Rendering.SelectListItem}

Returns:

An [System.Collections.Generic.IEnumerable`1]() containing the select list for the given <paramref name=”enumType” />.

IEnumerable<SelectListItem> GetEnumSelectList(Type enumType)
Microsoft.AspNet.Mvc.Rendering.IHtmlHelper.GetEnumSelectList<TEnum>()

Returns a select list for the given <typeparamref name=”TEnum” />.

Return type:System.Collections.Generic.IEnumerable{Microsoft.AspNet.Mvc.Rendering.SelectListItem}
Returns:An [System.Collections.Generic.IEnumerable`1]() containing the select list for the given <typeparamref name=”TEnum” />.
IEnumerable<SelectListItem> GetEnumSelectList<TEnum>()where TEnum : struct
Hidden(System.String, System.Object, System.Object)

Returns an &lt;input&gt; element of type “hidden” for the specified <paramref name=”expression” />.

Arguments:
  • expression (System.String) – Expression name, relative to the current model.
  • value (System.Object) – If non- <c>null</c>, value to include in the element.
  • htmlAttributes (System.Object) – An [System.Object]() that contains the HTML attributes for the element. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the HTML attributes.
Return type:

Microsoft.AspNet.Mvc.Rendering.HtmlString

Returns:

A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the &lt;input&gt; element.

HtmlString Hidden(string expression, object value, object htmlAttributes)
Id(System.String)

Returns the HTML element Id for the specified <paramref name=”expression” />.

Arguments:
  • expression (System.String) – Expression name, relative to the current model.
Return type:

System.String

Returns:

A [System.String]() containing the element Id.

string Id(string expression)
Label(System.String, System.String, System.Object)

Returns a &lt;label&gt; element for the specified <paramref name=”expression” />.

Arguments:
  • expression (System.String) – Expression name, relative to the current model.
  • labelText (System.String) – The inner text of the element.
  • htmlAttributes (System.Object) – An [System.Object]() that contains the HTML attributes for the element. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the HTML attributes.
Return type:

Microsoft.AspNet.Mvc.Rendering.HtmlString

Returns:

A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the &lt;label&gt; element.

HtmlString Label(string expression, string labelText, object htmlAttributes)
ListBox(System.String, System.Collections.Generic.IEnumerable<Microsoft.AspNet.Mvc.Rendering.SelectListItem>, System.Object)

Returns a multi-selection &lt;select&gt; element for the <paramref name=”expression” />, using the specified list items and HTML attributes.

Arguments:
  • expression (System.String) – Expression name, relative to the current model.
  • selectList (System.Collections.Generic.IEnumerable{Microsoft.AspNet.Mvc.Rendering.SelectListItem}) – A collection of [Microsoft.AspNet.Mvc.Rendering.SelectListItem](Microsoft.AspNet.Mvc.Rendering.SelectListItem.yml) objects used to populate the &lt;select&gt; element with &lt;optgroup&gt; and &lt;option&gt; elements.
  • htmlAttributes (System.Object) – An [System.Object]() that contains the HTML attributes for the &lt;select&gt; element. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the HTML attributes.
Return type:

Microsoft.AspNet.Mvc.Rendering.HtmlString

Returns:

A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the &lt;select&gt; element.

HtmlString ListBox(string expression, IEnumerable<SelectListItem> selectList, object htmlAttributes)
Name(System.String)

Returns the full HTML element name for the specified <paramref name=”expression” />.

Arguments:
  • expression (System.String) – Expression name, relative to the current model.
Return type:

System.String

Returns:

A [System.String]() containing the element name.

string Name(string expression)
PartialAsync(System.String, System.Object, Microsoft.AspNet.Mvc.ViewDataDictionary)

Returns HTML markup for the specified partial view.

Arguments:
  • partialViewName (System.String) – The name of the partial view used to create the HTML markup. Must not be <c>null</c>.
  • model (System.Object) – A model to pass into the partial view.
  • viewData (Microsoft.AspNet.Mvc.ViewDataDictionary) – A [Microsoft.AspNet.Mvc.ViewDataDictionary](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) to pass into the partial view.
Return type:

System.Threading.Tasks.Task{Microsoft.AspNet.Mvc.Rendering.HtmlString}

Returns:

A [System.Threading.Tasks.Task]() that on completion returns a new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the created HTML.

Task<HtmlString> PartialAsync(string partialViewName, object model, ViewDataDictionary viewData)
Password(System.String, System.Object, System.Object)

Returns an &lt;input&gt; element of type “password” for the specified <paramref name=”expression” />.

Arguments:
  • expression (System.String) – Expression name, relative to the current model.
  • value (System.Object) – If non- <c>null</c>, value to include in the element.
  • htmlAttributes (System.Object) – An [System.Object]() that contains the HTML attributes for the element. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the HTML attributes.
Return type:

Microsoft.AspNet.Mvc.Rendering.HtmlString

Returns:

A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the &lt;input&gt; element.

HtmlString Password(string expression, object value, object htmlAttributes)
RadioButton(System.String, System.Object, System.Nullable<System.Boolean>, System.Object)

Returns an &lt;input&gt; element of type “radio” for the specified <paramref name=”expression” />.

Arguments:
  • expression (System.String) – Expression name, relative to the current model.
  • value (System.Object) – If non- <c>null</c>, value to include in the element. Must not be <c>null</c> if <paramref name=”isChecked” /> is also <c>null</c> and no “checked” entry exists in <paramref name=”htmlAttributes” />.
  • isChecked (System.Nullable{System.Boolean}) – If <c>true</c>, radio button is initially selected. Must not be <c>null</c> if <paramref name=”value” /> is also <c>null</c> and no “checked” entry exists in <paramref name=”htmlAttributes” />.
  • htmlAttributes (System.Object) – An [System.Object]() that contains the HTML attributes for the element. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the HTML attributes.
Return type:

Microsoft.AspNet.Mvc.Rendering.HtmlString

Returns:

A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the &lt;input&gt; element.

HtmlString RadioButton(string expression, object value, bool ? isChecked, object htmlAttributes)
Raw(System.Object)

Wraps HTML markup from the string representation of an [System.Object]() in an [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml), without HTML-encoding the string representation.

Arguments:
  • value (System.Object) – The [System.Object]() to wrap.
Return type:

Microsoft.AspNet.Mvc.Rendering.HtmlString

Returns:

A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the wrapped string representation.

HtmlString Raw(object value)
Raw(System.String)

Wraps HTML markup in an [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml), without HTML-encoding the specified

<paramref name=”value” />.

Arguments:
  • value (System.String) – HTML markup [System.String]().
Return type:

Microsoft.AspNet.Mvc.Rendering.HtmlString

Returns:

A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the wrapped [System.String]().

HtmlString Raw(string value)
RenderPartialAsync(System.String, System.Object, Microsoft.AspNet.Mvc.ViewDataDictionary)

Renders HTML markup for the specified partial view.

Arguments:
  • partialViewName (System.String) – The name of the partial view used to create the HTML markup. Must not be <c>null</c>.
  • model (System.Object) – A model to pass into the partial view.
  • viewData (Microsoft.AspNet.Mvc.ViewDataDictionary) – A [Microsoft.AspNet.Mvc.ViewDataDictionary](Microsoft.AspNet.Mvc.ViewDataDictionary.yml) to pass into the partial view.
Return type:

System.Threading.Tasks.Task

Returns:

A [System.Threading.Tasks.Task]() that renders the created HTML when it executes.

Task RenderPartialAsync(string partialViewName, object model, ViewDataDictionary viewData)

Returns an anchor (&lt;a&gt;) element that contains a URL path to the specified route.

Arguments:
  • linkText (System.String) – The inner text of the anchor element. Must not be <c>null</c>.
  • routeName (System.String) – The name of the route.
  • protocol (System.String) – The protocol for the URL, such as “http” or “https”.
  • hostName (System.String) – The host name for the URL.
  • fragment (System.String) – The URL fragment name (the anchor name).
  • routeValues (System.Object) – An [System.Object]() that contains the parameters for a route. The parameters are retrieved through reflection by examining the properties of the [System.Object](). This [System.Object]() is typically created using [System.Object]() initializer syntax. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the route parameters.
  • htmlAttributes (System.Object) – An [System.Object]() that contains the HTML attributes for the element. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the HTML attributes.
Return type:

Microsoft.AspNet.Mvc.Rendering.HtmlString

Returns:

A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the anchor element.

HtmlString RouteLink(string linkText, string routeName, string protocol, string hostName, string fragment, object routeValues, object htmlAttributes)
TextArea(System.String, System.String, System.Int32, System.Int32, System.Object)

Returns a &lt;textarea&gt; element for the specified <paramref name=”expression” />.

Arguments:
  • expression (System.String) – Expression name, relative to the current model.
  • value (System.String) – If non- <c>null</c>, value to include in the element.
  • rows (System.Int32) – Number of rows in the textarea.
  • columns (System.Int32) – Number of columns in the textarea.
  • htmlAttributes (System.Object) – An [System.Object]() that contains the HTML attributes for the element. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the HTML attributes.
Return type:

Microsoft.AspNet.Mvc.Rendering.HtmlString

Returns:

A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the &lt;textarea&gt; element.

HtmlString TextArea(string expression, string value, int rows, int columns, object htmlAttributes)
TextBox(System.String, System.Object, System.String, System.Object)

Returns an &lt;input&gt; element of type “text” for the specified <paramref name=”current” />.

Arguments:
  • current (System.String) – Expression name, relative to the current model.
  • value (System.Object) – If non- <c>null</c>, value to include in the element.
  • format (System.String) – The composite format [System.String]() (see http://msdn.microsoft.com/en-us/library/txafckwd.aspx).
  • htmlAttributes (System.Object) – An [System.Object]() that contains the HTML attributes for the element. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the HTML attributes.
Return type:

Microsoft.AspNet.Mvc.Rendering.HtmlString

Returns:

A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing the &lt;input&gt; element.

HtmlString TextBox(string current, object value, string format, object htmlAttributes)
ValidationMessage(System.String, System.String, System.Object, System.String)

Returns the validation message if an error exists in the [Microsoft.AspNet.Mvc.ModelBinding.ModelStateDictionary]() object for the specified <paramref name=”expression” />.

Arguments:
  • expression (System.String) – Expression name, relative to the current model.
  • message (System.String) – The message to be displayed. If <c>null</c> or empty, method extracts an error string from the [Microsoft.AspNet.Mvc.ModelBinding.ModelStateDictionary]() object. Message will always be visible but client-side validation may update the associated CSS class.
  • htmlAttributes (System.Object) – An [System.Object]() that contains the HTML attributes for the <paramref name=”tag” /> element. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the HTML attributes.
  • tag (System.String) – The tag to wrap the <paramref name=”message” /> in the generated HTML. Its default value is [Microsoft.AspNet.Mvc.ViewContext.ValidationMessageElement](Microsoft.AspNet.Mvc.ViewContext.yml).
Return type:

Microsoft.AspNet.Mvc.Rendering.HtmlString

Returns:

A new [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing a <paramref name=”tag” /> element. <c>null</c> if the <paramref name=”expression” /> is valid and client-side validation is disabled.

HtmlString ValidationMessage(string expression, string message, object htmlAttributes, string tag)
ValidationSummary(System.Boolean, System.String, System.Object, System.String)

Returns an unordered list (&lt;ul&gt; element) of validation messages that are in the [Microsoft.AspNet.Mvc.ModelBinding.ModelStateDictionary]() object.

Arguments:
  • excludePropertyErrors (System.Boolean) – If <c>true</c>, display model-level errors only; otherwise display all errors.
  • message (System.String) – The message to display with the validation summary.
  • htmlAttributes (System.Object) – An [System.Object]() that contains the HTML attributes for the topmost (&lt;div&gt;) element. Alternatively, an [System.Collections.Generic.IDictionary`2]() instance containing the HTML attributes.
  • tag (System.String) – The tag to wrap the <paramref name=”message” /> in the generated HTML. Its default value is [Microsoft.AspNet.Mvc.ViewContext.ValidationSummaryMessageElement](Microsoft.AspNet.Mvc.ViewContext.yml).
Return type:

Microsoft.AspNet.Mvc.Rendering.HtmlString

Returns:

New [Microsoft.AspNet.Mvc.Rendering.HtmlString](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) containing a &lt;div&gt; element wrapping the <paramref name=”tag” /> element and the &lt;ul&gt; element. [Microsoft.AspNet.Mvc.Rendering.HtmlString.Empty](Microsoft.AspNet.Mvc.Rendering.HtmlString.yml) if the current model is valid and client-side validation is disabled).

HtmlString ValidationSummary(bool excludePropertyErrors, string message, object htmlAttributes, string tag)
Value(System.String, System.String)

Returns the formatted value for the specified <paramref name=”expression” />.

Arguments:
Return type:

System.String

Returns:

A [System.String]() containing the formatted value.

string Value(string expression, string format)