Button HtmlHelper Overview
The Telerik UI Button HtmlHelper for ASP.NET MVC is a server-side wrapper for the Kendo UI Button widget.
The Button provides a styled clickable UI functionality with arbitrary content. Apart from consistent Kendo UI for jQuery styling, the Button provides keyboard operability for elements, which natively do not have it—for example, span
.
Initializing the Button
The following example demonstrates how to define the Button by using the Button HtmlHelper.
@(Html.Kendo().Button()
.Name("textButton")
.HtmlAttributes( new {type = "button"} )
.Content("Text button"))
<%= Html.Kendo().Button()
.Name("textButton")
.HtmlAttributes( new {type = "button"} )
.Content("Text button") %>
The following example demonstrates how to initialize the Button by using the anchor
tag.
@(Html.Kendo().Button()
.Name("linkButton")
.Tag("a")
.Content("Link button"))
<%= Html.Kendo().Button()
.Name("linkButton")
.Tag("a")
.Content("Link button") %>
Basic Configuration
- The
Name()
configuration method is mandatory as its value will be used for theid
and thename
attributes of the Button element. Moreover, theid
is used in order to properly initialize the Button widget. Theid
attribute value is also used to retrieve its client-side instance. - The
Content()
configuration specifies the text that would be rendered in 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
Tag()
method allows the developer to determine whether the widget will be initialized from a<button>
element (by default), or from an<a>
element.
For a runnable example, refer to the demo on the basic usage of the Button.
Functionality and Features
Events
For a complete example on basic Button events, refer to the demo on using the events of the Button.
Referencing Existing Instances
To reference an existing Button instance, use the jQuery.data()
configuration option. Once a reference is established, use the Button client-side API.