ASP.NET MVC ToggleButton Overview

Telerik UI for ASP.NET MVC Ninja image

The ToggleButton is part of Telerik UI for ASP.NET MVC, a professional grade UI library with 110+ components for building modern and feature-rich applications. To try it out sign up for a free 30-day trial.

The Telerik UI ToggleButton HtmlHelper for ASP.NET MVC is a server-side wrapper for the Kendo UI ToggleButton widget.

The ToggleButton provides a styled clickable UI functionality with arbitrary content. Apart from consistent Kendo UI for jQuery styling, the ToggleButton enables you to indicate whether it is active or inactive, as well as group related options between various of ToggleButton components.

Initializing the ToggleButton

The following example demonstrates how to define the ToggleButton.

    .Content("Text ToggleButton")

Basic Configuration

  • The Name() configuration method is mandatory as its value is used for the id and the name attributes of the ToggleButton element. Moreover, the id is used to properly initialize the ToggleButton widget. You can also use the value of the id attribute to retrieve the client-side instance of the ToggleButton.
  • The Content() configuration specifies the text that is rendered within the button. This option does not accept HTML, but only string values.
  • The Enable() option determines whether the widget will be initially enabled (by default) of disabled.
  • The Group() option specifies a group of ToggleButtons the current instance belongs to.
  • The Tag() method allows the developer to determine whether the widget will be initialized from a <button> element (by default), or from an <a> element.

The following example demonstrates the available configuration options for the ToggleButton.

    .Content("Sample Button")

<script type="text/javascript">
    $(function() {
        // The Name() of the ToggleButton is used to get its client-side instance.
        var togglebutton = $("#toggleButton").data("kendoToggleButton");

Functionality and Features

  • Group ToggleButton—You can group several ToggleButton instances together.
  • Icon ToggleButton—The variety of icons allow you to enhance the appearance of the button.
  • Badge ToggleButton—You can add a Badge to the ToggleButton to conveniently show its status, a notification, or a short message.
  • Events—The ToggleButton allows you to handle its click event and implement custom functionality.

Next Steps

See Also

In this article