This section briefly explains about how to include a simple CheckBox in your ASP.NET MVC application. You can refer ASP.NET MVC Getting Started documentation page for introduction part of the system requirements and configure the common specifications.
We are going to render CheckBox
component in Index.cshtml page.
@Html.EJS().CheckBox("default").Label("Default").Render()
public ActionResult Default()
{
return View();
}
Output be like the below.
After successful compilation of your application, simply press F5
to run the application.
The following example shows a default rendering of CheckBox.
@Html.EJS().CheckBox("default").Label("Default").Render()
public ActionResult Default()
{
return View();
}
The Essential JS 2 CheckBox contains 3 different states visually, they are:
The CheckBox checked
property is used to handle the checked and unchecked state.
In checked state a tick mark will be added to the visualization of CheckBox.
The CheckBox indeterminate state can be set through indeterminate
property.
CheckBox indeterminate state masks the real value of CheckBox visually. The Checkbox cannot be changed to indeterminate state through the user interface,
this state can be achieved only through the property.
@Html.EJS().CheckBox("checked").Label("Checked State").Checked(true).Render()
@Html.EJS().CheckBox("unchecked").Label("Unchecked State").Render()
@Html.EJS().CheckBox("indeterminate").Label("Intermediate State").Indeterminate(true).Render()
<style>
.e-checkbox-wrapper {
margin-top: 18px;
}
li {
list-style: none;
}
</style>
public ActionResult State()
{
return View();
}