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.
We are going to render Switch
component in Index.cshtml page.
@Html.EJS().Switch("default").Render()
public ActionResult Default()
{
return View();
}
After successful compilation of your application, simply press F5
to run the application.
The following example shows a default rendering of Switch.
@Html.EJS().Switch("default").Render()
public ActionResult Default()
{
return View();
}
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
.
@Html.EJS().Switch("default").OnLabel("ON").OffLabel("OFF").Render()
public ActionResult Default()
{
return View();
}
Switch does not have text support for material themes, and does not support long custom text.