Search results

Getting Started

This section briefly explains about how to create a simple Switch 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 Switch to the project

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

tagHelper
default.cs
<ejs-switch id="default"></ejs-switch>
public IActionResult Default()
    {
            return View();
    }

Run the application

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

The following example shows a default rendering of Switch.

tagHelper
default.cs
<ejs-switch id="default"></ejs-switch>
public IActionResult Default()
    {
            return View();
    }

Set text on Switch

This section explains how to set onLabel and offLabel texts on Switch. In the following example, onLabel is set as ON and offLabel is set as OFF.

tagHelper
default.cs
<ejs-switch id="default" onlabel="ON" offlabel="OFF"></ejs-switch>
public IActionResult Default()
    {
            return View();
    }

Switch does not have text support for material themes, and does not support long custom text.

See Also