TextBox HtmlHelper Overview
The Telerik UI TextBox HtmlHelper for ASP.NET MVC is a server-side wrapper for the Kendo UI TextBox widget.
The TextBox provides a set of default API configuration options that can be set during its initialization such as value, placeholder, and so on.
The TextBox is part of Telerik UI for ASP.NET MVC, a
professional grade UI library with 100+ components for building modern and feature-rich applications. To try it out sign up for a free 30-day trial.
Basic Configuration
The following example demonstrates the basic configuration for the TextBox.
@(Html.Kendo().TextBox()
.Name("textbox") // The name of the TextBox is mandatory. It specifies the "id" attribute of the TextBox.
.Value("John Doe") // Set the value of the TextBox.
)
Functionality and Features
Events
You can subscribe to the TextBox events. For a complete example on basic TextBox events, refer to the demo on using the events of the TextBox.
The following example demonstrates how to subscribe to events by a handler name.
@(Html.Kendo().TextBox()
.Name("textbox")
.Events(e => e
.Change("textbox_change")
)
)
<script>
function textbox_change() {
// Handle the change event.
}
</script>
Referencing Existing Instances
To reference an existing Telerik UI TextBox instance, use the jQuery.data()
method. Once a reference is established, use the TextBox client-side API to control its behavior.
The following example demonstrates how to access an existing TextBox instance.
// Place the following after your Telerik UI TextBox for ASP.NET MVC declaration.
<script>
$(function() {
// The Name() of the TextBox is used to get its client-side instance.
var textbox = $("#textbox").data("kendoTextBox");
});
</script>