This section briefly explains about how to include a simple RadioButton 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 RadioButton
component in Index.cshtml page.
@Html.EJS().RadioButton("radio1").Label("Option 1").Name("default").Render()
@Html.EJS().RadioButton("radio2").Label("Option 2").Name("default").Render()
public ActionResult Index()
{
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 RadioButton.
@Html.EJS().RadioButton("radio1").Label("Option 1").Name("default").Render()
@Html.EJS().RadioButton("radio2").Label("Option 2").Name("default").Render()
public ActionResult Index()
{
return View();
}
The Essential JS 2 RadioButton contains 2 states visually, they are as follows:
The RadioButton checked
property is used to handle the checked and unchecked state.
In the checked state an inner circle will be added to the visualization of RadioButton.
@Html.EJS().RadioButton("radio1").Label("Option 1").Name("state").Checked(true).Render()
@Html.EJS().RadioButton("radio2").Label("Option 2").Name("state").Render()
public ActionResult state()
{
return View();
}