HtmlHelperInputExtensions.CheckBox HtmlHelperInputExtensions.CheckBox HtmlHelperInputExtensions.CheckBox Method

Definition

Overloads

CheckBox(IHtmlHelper, String) CheckBox(IHtmlHelper, String) CheckBox(IHtmlHelper, String)

Returns an <input> element of type "checkbox" with value "true" and an <input> element of type "hidden" with value "false" for the specified expression. Adds a "checked" attribute to the "checkbox" element based on the first non-null value found in: the ModelState entry with full name, the ViewData entry with full name, or the expression evaluated against Model. See Name(String) for more information about a "full name".

CheckBox(IHtmlHelper, String, Boolean) CheckBox(IHtmlHelper, String, Boolean) CheckBox(IHtmlHelper, String, Boolean)

Returns an <input> element of type "checkbox" with value "true" and an <input> element of type "hidden" with value "false" for the specified expression. Adds a "checked" attribute to the "checkbox" element based on the first non-null value found in: the ModelState entry with full name, the isChecked parameter, the ViewData entry with full name, or the expression evaluated against Model. See Name(String) for more information about a "full name".

CheckBox(IHtmlHelper, String, Object) CheckBox(IHtmlHelper, String, Object) CheckBox(IHtmlHelper, String, Object)

Returns an <input> element of type "checkbox" with value "true" and an <input> element of type "hidden" with value "false" for the specified expression. Adds a "checked" attribute to the "checkbox" element based on the first non-null value found in: the htmlAttributes dictionary entry with key "checked", the ModelState entry with full name, the ViewData entry with full name, or the expression evaluated against Model. See Name(String) for more information about a "full name".

CheckBox(IHtmlHelper, String) CheckBox(IHtmlHelper, String) CheckBox(IHtmlHelper, String)

Returns an <input> element of type "checkbox" with value "true" and an <input> element of type "hidden" with value "false" for the specified expression. Adds a "checked" attribute to the "checkbox" element based on the first non-null value found in: the ModelState entry with full name, the ViewData entry with full name, or the expression evaluated against Model. See Name(String) for more information about a "full name".

public static Microsoft.AspNetCore.Html.IHtmlContent CheckBox (this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper, string expression);
static member CheckBox : Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper * string -> Microsoft.AspNetCore.Html.IHtmlContent
<Extension()>
Public Function CheckBox (htmlHelper As IHtmlHelper, expression As String) As IHtmlContent

Parameters

htmlHelper
IHtmlHelper IHtmlHelper IHtmlHelper

The IHtmlHelper instance this method extends.

expression
String String String

Expression name, relative to the current model.

Returns

A new IHtmlContent containing the <input> elements.

Remarks

Combines HtmlFieldPrefix and expression to set checkbox element's "name" attribute. Sanitizes expression to set checkbox element's "id" attribute.

CheckBox(IHtmlHelper, String, Boolean) CheckBox(IHtmlHelper, String, Boolean) CheckBox(IHtmlHelper, String, Boolean)

Returns an <input> element of type "checkbox" with value "true" and an <input> element of type "hidden" with value "false" for the specified expression. Adds a "checked" attribute to the "checkbox" element based on the first non-null value found in: the ModelState entry with full name, the isChecked parameter, the ViewData entry with full name, or the expression evaluated against Model. See Name(String) for more information about a "full name".

public static Microsoft.AspNetCore.Html.IHtmlContent CheckBox (this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper, string expression, bool isChecked);
static member CheckBox : Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper * string * bool -> Microsoft.AspNetCore.Html.IHtmlContent
<Extension()>
Public Function CheckBox (htmlHelper As IHtmlHelper, expression As String, isChecked As Boolean) As IHtmlContent

Parameters

htmlHelper
IHtmlHelper IHtmlHelper IHtmlHelper

The IHtmlHelper instance this method extends.

expression
String String String

Expression name, relative to the current model.

isChecked
Boolean Boolean Boolean

If true, checkbox is initially checked.

Returns

A new IHtmlContent containing the <input> elements.

Remarks

Combines HtmlFieldPrefix and expression to set checkbox element's "name" attribute. Sanitizes expression to set checkbox element's "id" attribute.

CheckBox(IHtmlHelper, String, Object) CheckBox(IHtmlHelper, String, Object) CheckBox(IHtmlHelper, String, Object)

Returns an <input> element of type "checkbox" with value "true" and an <input> element of type "hidden" with value "false" for the specified expression. Adds a "checked" attribute to the "checkbox" element based on the first non-null value found in: the htmlAttributes dictionary entry with key "checked", the ModelState entry with full name, the ViewData entry with full name, or the expression evaluated against Model. See Name(String) for more information about a "full name".

public static Microsoft.AspNetCore.Html.IHtmlContent CheckBox (this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper, string expression, object htmlAttributes);
static member CheckBox : Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper * string * obj -> Microsoft.AspNetCore.Html.IHtmlContent
<Extension()>
Public Function CheckBox (htmlHelper As IHtmlHelper, expression As String, htmlAttributes As Object) As IHtmlContent

Parameters

htmlHelper
IHtmlHelper IHtmlHelper IHtmlHelper

The IHtmlHelper instance this method extends.

expression
String String String

Expression name, relative to the current model.

htmlAttributes
Object Object Object

An Object that contains the HTML attributes for the checkbox element. Alternatively, an IDictionary<TKey,TValue> instance containing the HTML attributes.

Returns

A new IHtmlContent containing the <input> elements.

Remarks

Combines HtmlFieldPrefix and expression to set checkbox element's "name" attribute. Sanitizes expression to set checkbox element's "id" attribute.

Applies to