Search results

Getting started with ASP.NET Core RadioButton control

26 Oct 2021 / 1 minute to read

This section briefly explains about how to create a simple SplitButton in your ASP.NET Core application. You can refer ASP.NET Core Getting Started documentation page for introduction part of the system requirements and configure the common specifications.

Add RadioButton to the project

To create simple RadioButton add the ejs-radiobutton tag with id attribute as element in your Index.cshtml page.

tagHelper
default.cs
Copied to clipboard
<ejs-radiobutton id="radio1" label="Option 1" name="default"></ejs-radiobutton>
<ejs-radiobutton id="radio2" label="Option 2" name="default" checked="true"></ejs-radiobutton>
Copied to clipboard
public ActionResult Index()
    {
            return View();
    }

Output be like the below.

RadioButton Sample

Run the application

After successful compilation of your application, simply press F5 to run the application.

The following example shows a default rendering of RadioButton.

tagHelper
default.cs
Copied to clipboard
<ejs-radiobutton id="radio1" label="Option 1" name="default"></ejs-radiobutton>
<ejs-radiobutton id="radio2" label="Option 2" name="default" checked="true"></ejs-radiobutton>
Copied to clipboard
public ActionResult Index()
    {
            return View();
    }

Change the RadioButton state

The Essential JS 2 RadioButton contains 2 states visually, they are as follows:

  • Checked
  • Unchecked

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.

tagHelper
state.cs
Copied to clipboard
<ejs-radiobutton id="radio1" label="Option 1" name="state" checked="true"></ejs-radiobutton>
<ejs-radiobutton id="radio2" label="Option 2" name="state"></ejs-radiobutton>
Copied to clipboard
public ActionResult state()
    {
            return View();
    }