Search results

Getting Started

This section briefly explains about how to include a simple Switch 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.

Add Switch to the project

We are going to render Switch component in Index.cshtml page.

razor
default.cs
@Html.EJS().Switch("default").Render()
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.

razor
default.cs
@Html.EJS().Switch("default").Render()
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.

razor
default.cs
@Html.EJS().Switch("default").OnLabel("ON").OffLabel("OFF").Render()
public IActionResult Default()
    {
            return View();
    }

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

See Also