HtmlHelperInputExtensions.CheckBoxFor<TModel> Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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, or
the expression
evaluated against Model.
See NameFor<TResult>(Expression<Func<TModel,TResult>>) for more information about a "full name".
public:
generic <typename TModel>
[System::Runtime::CompilerServices::Extension]
static Microsoft::AspNetCore::Html::IHtmlContent ^ CheckBoxFor(Microsoft::AspNetCore::Mvc::Rendering::IHtmlHelper<TModel> ^ htmlHelper, System::Linq::Expressions::Expression<Func<TModel, bool> ^> ^ expression);
public static Microsoft.AspNetCore.Html.IHtmlContent CheckBoxFor<TModel> (this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<TModel> htmlHelper, System.Linq.Expressions.Expression<Func<TModel,bool>> expression);
static member CheckBoxFor : Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper<'Model> * System.Linq.Expressions.Expression<Func<'Model, bool>> -> Microsoft.AspNetCore.Html.IHtmlContent
<Extension()>
Public Function CheckBoxFor(Of TModel) (htmlHelper As IHtmlHelper(Of TModel), expression As Expression(Of Func(Of TModel, Boolean))) As IHtmlContent
- TModel
- htmlHelper
- IHtmlHelper<TModel>
The IHtmlHelper<TModel> instance this method extends.
- expression
- Expression<Func<TModel,Boolean>>
An expression to be evaluated against the current model.
A new IHtmlContent containing the <input> elements.
Combines HtmlFieldPrefix and the string representation of the expression
to set checkbox element's "name" attribute. Sanitizes the string representation of the expression
to set checkbox element's "id" attribute.
Product | Versions |
---|---|
ASP.NET Core | 1.0, 1.1, 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0 |