HtmlHelperInputExtensions Class

Input-related extensions for Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper and Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper`1.

Namespace
Microsoft.AspNetCore.Mvc.Rendering
Assemblies
  • Microsoft.AspNetCore.Mvc.ViewFeatures

Syntax

public class HtmlHelperInputExtensions
class Microsoft.AspNetCore.Mvc.Rendering.HtmlHelperInputExtensions

Methods

CheckBox(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String)

Returns an <input> element of type “checkbox” with value “true” and an <input> element of type “hidden” with value “false”.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <input> elements.

public static IHtmlContent CheckBox(this IHtmlHelper htmlHelper, string expression)
CheckBox(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.Boolean)

Returns an <input> element of type “checkbox” with value “true” and an <input> element of type “hidden” with value “false”.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <input> elements.

public static IHtmlContent CheckBox(this IHtmlHelper htmlHelper, string expression, bool isChecked)
CheckBox(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.Object)

Returns an <input> element of type “checkbox” with value “true” and an <input> element of type “hidden” with value “false”.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <input> elements.

public static IHtmlContent CheckBox(this IHtmlHelper htmlHelper, string expression, object htmlAttributes)
CheckBoxFor<TModel>(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel, System.Boolean>>)

Returns an <input> element of type “checkbox” with value “true” and an <input> element of type “hidden” with value “false”.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <input> elements.

public static IHtmlContent CheckBoxFor<TModel>(this IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, bool>> expression)
Hidden(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String)

Returns an <input> element of type “hidden” for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <input> element.

public static IHtmlContent Hidden(this IHtmlHelper htmlHelper, string expression)
Hidden(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.Object)

Returns an <input> element of type “hidden” for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <input> element.

public static IHtmlContent Hidden(this IHtmlHelper htmlHelper, string expression, object value)
HiddenFor<TModel, TResult>(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel, TResult>>)

Returns an <input> element of type “hidden” for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <input> element.

public static IHtmlContent HiddenFor<TModel, TResult>(this IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TResult>> expression)
Password(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String)

Returns an <input> element of type “password” for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <input> element.

public static IHtmlContent Password(this IHtmlHelper htmlHelper, string expression)
Password(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.Object)

Returns an <input> element of type “password” for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <input> element.

public static IHtmlContent Password(this IHtmlHelper htmlHelper, string expression, object value)
PasswordFor<TModel, TResult>(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel, TResult>>)

Returns an <input> element of type “password” for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <input> element.

public static IHtmlContent PasswordFor<TModel, TResult>(this IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TResult>> expression)
RadioButton(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.Object)

Returns an <input> element of type “radio” for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <input> element.

public static IHtmlContent RadioButton(this IHtmlHelper htmlHelper, string expression, object value)
RadioButton(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.Object, System.Boolean)

Returns an <input> element of type “radio” for the specified <em>expression</em>.

Arguments:
  • htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper instance this method extends.
  • expression (System.String) – Expression name, relative to the current model.
  • value (System.Object) – If non-<code>null</code>, value to include in the element. Must not be <code>null</code> if <em>isChecked</em> is also <code>null</code>.
  • isChecked (System.Boolean) – If <code>true</code>, radio button is initially selected. Must not be <code>null</code> if <em>value</em> is also <code>null</code>.
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <input> element.

public static IHtmlContent RadioButton(this IHtmlHelper htmlHelper, string expression, object value, bool isChecked)
RadioButton(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.Object, System.Object)

Returns an <input> element of type “radio” for the specified <em>expression</em>.

Arguments:
  • htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper instance this method extends.
  • expression (System.String) – Expression name, relative to the current model.
  • value (System.Object) – If non-<code>null</code>, value to include in the element. Must not be <code>null</code> if no “checked” entry exists in <em>htmlAttributes</em>.
  • 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.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <input> element.

public static IHtmlContent RadioButton(this IHtmlHelper htmlHelper, string expression, object value, object htmlAttributes)
RadioButtonFor<TModel, TResult>(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel, TResult>>, System.Object)

Returns an <input> element of type “radio” for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <input> element.

public static IHtmlContent RadioButtonFor<TModel, TResult>(this IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TResult>> expression, object value)
TextArea(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String)

Returns a <textarea> element for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <textarea> element.

public static IHtmlContent TextArea(this IHtmlHelper htmlHelper, string expression)
TextArea(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.Object)

Returns a <textarea> element for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <textarea> element.

public static IHtmlContent TextArea(this IHtmlHelper htmlHelper, string expression, object htmlAttributes)
TextArea(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.String)

Returns a <textarea> element for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <textarea> element.

public static IHtmlContent TextArea(this IHtmlHelper htmlHelper, string expression, string value)
TextArea(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.String, System.Object)

Returns a <textarea> element for the specified <em>expression</em>.

Arguments:
  • htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper instance this method extends.
  • expression (System.String) – Expression name, relative to the current model.
  • value (System.String) – If non-<code>null</code>, 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.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <textarea> element.

public static IHtmlContent TextArea(this IHtmlHelper htmlHelper, string expression, string value, object htmlAttributes)
TextAreaFor<TModel, TResult>(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel, TResult>>)

Returns a <textarea> element for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <textarea> element.

public static IHtmlContent TextAreaFor<TModel, TResult>(this IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TResult>> expression)
TextAreaFor<TModel, TResult>(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel, TResult>>, System.Object)

Returns a <textarea> element for the specified <em>expression</em>.

Arguments:
  • htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>) – The Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper`1 instance this method extends.
  • expression (System.Linq.Expressions.Expression<System.Func<TModel, TResult>>) – An expression to be evaluated against the current model.
  • 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.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <textarea> element.

public static IHtmlContent TextAreaFor<TModel, TResult>(this IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TResult>> expression, object htmlAttributes)
TextBox(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String)

Returns an <input> element of type “text” for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <input> element.

public static IHtmlContent TextBox(this IHtmlHelper htmlHelper, string expression)
TextBox(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.Object)

Returns an <input> element of type “text” for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <input> element.

public static IHtmlContent TextBox(this IHtmlHelper htmlHelper, string expression, object value)
TextBox(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.Object, System.Object)

Returns an <input> element of type “text” for the specified <em>expression</em>.

Arguments:
  • htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper) – The Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper instance this method extends.
  • expression (System.String) – Expression name, relative to the current model.
  • value (System.Object) – If non-<code>null</code>, 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.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <input> element.

public static IHtmlContent TextBox(this IHtmlHelper htmlHelper, string expression, object value, object htmlAttributes)
TextBox(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper, System.String, System.Object, System.String)

Returns an <input> element of type “text” for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <input> element.

public static IHtmlContent TextBox(this IHtmlHelper htmlHelper, string expression, object value, string format)
TextBoxFor<TModel, TResult>(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel, TResult>>)

Returns an <input> element of type “text” for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <input> element.

public static IHtmlContent TextBoxFor<TModel, TResult>(this IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TResult>> expression)
TextBoxFor<TModel, TResult>(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel, TResult>>, System.Object)

Returns an <input> element of type “text” for the specified <em>expression</em>.

Arguments:
  • htmlHelper (Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>) – The Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper`1 instance this method extends.
  • expression (System.Linq.Expressions.Expression<System.Func<TModel, TResult>>) – An expression to be evaluated against the current model.
  • 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.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <input> element.

public static IHtmlContent TextBoxFor<TModel, TResult>(this IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TResult>> expression, object htmlAttributes)
TextBoxFor<TModel, TResult>(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel, TResult>>, System.String)

Returns an <input> element of type “text” for the specified <em>expression</em>.

Arguments:
Return type:

Microsoft.AspNetCore.Html.IHtmlContent

Returns:

A new Microsoft.AspNetCore.Html.IHtmlContent containing the <input> element.

public static IHtmlContent TextBoxFor<TModel, TResult>(this IHtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TResult>> expression, string format)