-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kendo Bot
committed
Jan 18, 2023
1 parent
3b60408
commit 0df12ac
Showing
17 changed files
with
1,549 additions
and
349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
title: Events | ||
page_title: Events | ||
description: "Learn how to handle the events of the Telerik UI TextBox component for {{ site.framework }}." | ||
slug: events_textbox_aspnetcore | ||
position: 7 | ||
--- | ||
|
||
# Events | ||
|
||
The Telerik UI TextBox for {{ site.framework }} exposes multiple [events](/api/Kendo.Mvc.UI.Fluent/TextBoxEventBuilder) that allow you to control and customize the behavior of the UI component. | ||
|
||
For a complete example on basic TextBox events, refer to the [demo on using the events of the TextBox](https://demos.telerik.com/{{ site.platform }}/textbox/events). | ||
|
||
## Handling by Handler Name | ||
|
||
The following example demonstrates how to subscribe to events by a handler name. | ||
|
||
|
||
```HtmlHelper | ||
@(Html.Kendo().TextBox() | ||
.Name("textbox") | ||
.Events(e => e | ||
.Change("textbox_change") | ||
) | ||
) | ||
``` | ||
{% if site.core %} | ||
```TagHelper | ||
<kendo-textbox name="textbox" | ||
on-change="textbox_change"> | ||
</kendo-textbox> | ||
``` | ||
{% endif %} | ||
```script.js | ||
<script> | ||
function textbox_change() { | ||
// Handle the change event. | ||
} | ||
</script> | ||
``` | ||
|
||
## Next Steps | ||
|
||
* [Using the TextBox Events (Demo)](https://demos.telerik.com/{{ site.platform }}/textbox/events) | ||
|
||
## See Also | ||
|
||
* [Using the API of the TextBox HtmlHelper for {{ site.framework }} (Demo)](https://demos.telerik.com/{{ site.platform }}/textbox/api) | ||
* [TextBox Server-Side API](/api/textbox) | ||
* [TextBox Client-Side API](https://docs.telerik.com/kendo-ui/api/javascript/ui/textbox) |
192 changes: 192 additions & 0 deletions
192
docs-aspnet/html-helpers/editors/textbox/getting-started.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
--- | ||
title: Getting Started | ||
page_title: Getting Started | ||
description: "Make your first steps with the Telerik UI for {{ site.framework }} TextBox component by following a complete step-by-step tutorial." | ||
slug: aspnetcore_textbox_getting_started | ||
position: 1 | ||
--- | ||
|
||
# Getting Started with the TextBox | ||
|
||
This tutorial explains how to set up a basic Telerik UI for {{ site.framework }} TextBox and highlights the major steps in the configuration of the component. | ||
|
||
You will initialize a TextBox component with a placeholder text and a label. {% if site.core %}Finally, you can run the sample code in [Telerik REPL](https://netcorerepl.telerik.com/) and continue exploring the components.{% endif %} | ||
|
||
![Sample Telerik UI for {{ site.framework }} TextBox](./images/textbox-getting-started.png) | ||
|
||
@[template](/_contentTemplates/core/getting-started-prerequisites.md#repl-component-gs-prerequisites) | ||
|
||
## 1. Prepare the CSHTML File | ||
|
||
@[template](/_contentTemplates/core/getting-started-directives.md#gs-adding-directives) | ||
|
||
You will also add some sample value that the TextBox will present to the user. Optionally, you can structure the document by adding the desired HTML elements like headings, divs, paragraphs, and others. | ||
|
||
```HtmlHelper | ||
@using Kendo.Mvc.UI | ||
<h4>TextBox with a Placeholder</h4> | ||
<div> | ||
</div> | ||
``` | ||
{% if site.core %} | ||
```TagHelper | ||
@addTagHelper *, Kendo.Mvc | ||
<h4>TextBox with a Placeholder</h4> | ||
<div> | ||
</div> | ||
``` | ||
{% endif %} | ||
|
||
## 2. Initialize the TextBox | ||
|
||
Use the TextBox HtmlHelper {% if site.core %}or TagHelper{% endif %} to add the component to a page: | ||
|
||
* The `Name()` configuration method is mandatory as its value is used for the `id` and the name attributes of the TextBox element. | ||
* The `Placeholder()` configuration specifies the dummy text that is shown initially to hint the user. | ||
|
||
```HtmlHelper | ||
@using Kendo.Mvc.UI | ||
<h4>TextBox with a Placeholder</h4> | ||
<div> | ||
@(Html.Kendo().TextBox() | ||
.Name("textbox") | ||
.Placeholder("Name...") | ||
.HtmlAttributes(new { style = "width: 300px;" }) | ||
) | ||
</div> | ||
``` | ||
{% if site.core %} | ||
```TagHelper | ||
@addTagHelper *, Kendo.Mvc | ||
<h4>TextBox with a Placeholder</h4> | ||
<div> | ||
<kendo-textbox name="textbox" style="width: 300px;" | ||
placeholder="Name..."> | ||
</kendo-textbox> | ||
</div> | ||
``` | ||
{% endif %} | ||
|
||
## 3. Define a Label Text | ||
|
||
The next step is to present some description text in front of the TextBox component using the `Label()` property. | ||
|
||
```HtmlHelper | ||
@using Kendo.Mvc.UI | ||
<h4>TextBox with a Placeholder</h4> | ||
<div> | ||
@(Html.Kendo().TextBox() | ||
.Name("textbox") | ||
.Label(l => l.Content("Set value:")) | ||
.Placeholder("Name...") | ||
.HtmlAttributes(new { style = "width: 300px;" }) | ||
) | ||
</div> | ||
``` | ||
{% if site.core %} | ||
```TagHelper | ||
@addTagHelper *, Kendo.Mvc | ||
<h4>TextBox with a Placeholder</h4> | ||
<div> | ||
<kendo-textbox name="textbox" style="width: 300px;" placeholder="Name..."> | ||
<textbox-label content="Set value:"/> | ||
</kendo-textbox> | ||
</div> | ||
``` | ||
{% endif %} | ||
|
||
## 4. Handle a TextBox Event | ||
|
||
The TextBox component provides convenient events for implementing your desired logic. In this tutorial, you will use the exposed `Change()` event to log a new entry in the browser's console. | ||
|
||
```HtmlHelper | ||
@using Kendo.Mvc.UI | ||
<h4>TextBox with a Placeholder</h4> | ||
<div> | ||
<script> | ||
function change(e) { | ||
console.log("Change :: " + this.value()); | ||
} | ||
</script> | ||
@(Html.Kendo().TextBox() | ||
.Name("textbox") | ||
.Label(l => l.Content("Set value:")) | ||
.Placeholder("Name...") | ||
.Events(e => e.Change("change")) | ||
.HtmlAttributes(new { style = "width: 300px;" }) | ||
) | ||
</div> | ||
``` | ||
{% if site.core %} | ||
```TagHelper | ||
@addTagHelper *, Kendo.Mvc | ||
<h4>TextBox with a Placeholder</h4> | ||
<div> | ||
<script> | ||
function change(e) { | ||
console.log("Change :: " + this.value()); | ||
} | ||
</script> | ||
<kendo-textbox name="textbox" style="width: 300px;" | ||
placeholder="Name..." on-change="change"> | ||
<textbox-label content="Set value:"/> | ||
</kendo-textbox> | ||
</div> | ||
``` | ||
{% endif %} | ||
|
||
## 5. (Optional) Reference Existing TextBox Instances | ||
|
||
You can reference the TextBox instances that you have created and build on top of their existing configuration: | ||
|
||
1. Use the `id` attribute of the component instance to establish a reference. | ||
|
||
```script | ||
<script> | ||
var textboxReference = $("#textbox").data("kendoTextBox"); // textboxReference is a reference to the existing TextBox instance of the helper. | ||
</script> | ||
``` | ||
1. Use the [TextBox client-side API](https://docs.telerik.com/kendo-ui/api/javascript/ui/textbox#methods) to control the behavior of the widget. In this example, you will use the `value` method to select an item. | ||
```script | ||
<script> | ||
var textboxReference = $("#textbox").data("kendoTextBox"); // textboxReference is a reference to the existing TextBox instance of the helper. | ||
textboxReference.value("Sample text"); | ||
</script> | ||
``` | ||
{% if site.core %} | ||
## Explore this Tutorial in REPL | ||
You can continue experimenting with the code sample above by running it in the Telerik REPL server playground: | ||
* [Sample code with the TextBox HtmlHelper](https://netcorerepl.telerik.com/QHEvbJFL14nUQBCX42) | ||
* [Sample code with the TextBox TagHelper](https://netcorerepl.telerik.com/GnObbJFh14nVCZns54) | ||
{% endif %} | ||
## Next Steps | ||
* [Set Labels to the TextBox]({% slug htmlhelpers_labels_textbox %}) | ||
* [Customize the Appearance of the TextBox]({% slug textbox_appearance %}) | ||
* [Accessibility]({% slug accessibility_textbox_aspnetcore %}) | ||
## See Also | ||
* [Using the API of the TextBox for {{ site.framework }} (Demo)](https://demos.telerik.com/{{ site.platform }}/textbox/api) | ||
* [TextBox Client-Side API](https://docs.telerik.com/kendo-ui/api/javascript/ui/textbox) | ||
* [Server-Side API of the TextBox](/api/textbox) | ||
* [Knowledge Base Section](/knowledge-base) |
Binary file added
BIN
+7.13 KB
docs-aspnet/html-helpers/editors/textbox/images/textbox-getting-started.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.