HtmlHelperInputExtensions.CheckBox Method

Definition

Overloads

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)

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)

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)

Source:
HtmlHelperInputExtensions.cs
Source:
HtmlHelperInputExtensions.cs
Source:
HtmlHelperInputExtensions.cs

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:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::AspNetCore::Html::IHtmlContent ^ CheckBox(Microsoft::AspNetCore::Mvc::Rendering::IHtmlHelper ^ htmlHelper, System::String ^ expression);
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

The IHtmlHelper instance this method extends.

expression
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.

Applies to

CheckBox(IHtmlHelper, String, Boolean)

Source:
HtmlHelperInputExtensions.cs
Source:
HtmlHelperInputExtensions.cs
Source:
HtmlHelperInputExtensions.cs

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:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::AspNetCore::Html::IHtmlContent ^ CheckBox(Microsoft::AspNetCore::Mvc::Rendering::IHtmlHelper ^ htmlHelper, System::String ^ expression, bool isChecked);
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

The IHtmlHelper instance this method extends.

expression
String

Expression name, relative to the current model.

isChecked
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.

Applies to

CheckBox(IHtmlHelper, String, Object)

Source:
HtmlHelperInputExtensions.cs
Source:
HtmlHelperInputExtensions.cs
Source:
HtmlHelperInputExtensions.cs

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:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::AspNetCore::Html::IHtmlContent ^ CheckBox(Microsoft::AspNetCore::Mvc::Rendering::IHtmlHelper ^ htmlHelper, System::String ^ expression, System::Object ^ htmlAttributes);
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

The IHtmlHelper instance this method extends.

expression
String

Expression name, relative to the current model.

htmlAttributes
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