Unplanned
Last Updated: 02 Feb 2023 11:06 by Paul
Created by: Paul
Comments: 0
Category: TextBox
Type: Feature Request
2
Is it possible to create an option to encode the TextBox value similar to the encoded option of the Editor?
Unplanned
Last Updated: 14 Jun 2021 14:38 by ADMIN
Created by: Jon
Comments: 2
Category: TextBox
Type: Feature Request
2

Feature Request

Create TexBox label from ViewModel Data Annotation

Currently, this is possible using the default @Html.Label, and @Html.Textbox

-Model:

     [DisplayName("First Name :")]

public string FirstName { get; set; }

-View

        <tr>
         <td>
                @ Html.LabelFor(m=>m.FirstName)
            </td>
            <td>
                @Html.TextBoxFor(m=>m.FirstName)                
            </td>
        </tr>

Unplanned
Last Updated: 11 Jun 2021 05:56 by ADMIN
Created by: Eyup
Comments: 0
Category: TextBox
Type: Feature Request
3

Data Model

[Required]
[StringLength(128)]
[DisplayName("Password")]
[DataType(DataType.Password)]
public string UserPassword { get; set; }
Razor HTML
<div class="form-group">
  <kendo-textbox name="UserPassword" type="password"> <!-HOW to use DataType Annotation here? -- >
      <textbox-label content="@Html.DisplayNameFor(m=>m.UserPassword)" floating="true" />
   </kendo-textbox>
</div>
This scenario is working for a regular <input asp-for="FieldName"/> so it also should work for Telerik TextBox widget as well.

 

The solution below can be used as a workaround for the time being:

@{ Dictionary<string, string> fieldTypes = new Dictionary<string, string>();
    var properties = typeof(TestModel).GetProperties();
    foreach (var property in properties)
    {
        var dataTypeAttributes = property.GetCustomAttributes(
            typeof(System.ComponentModel.DataAnnotations.DataTypeAttribute), false);
        if (dataTypeAttributes.Length > 0)
        {
            var attribute = dataTypeAttributes[0] as
        System.ComponentModel.DataAnnotations.DataTypeAttribute;
            var dataType = (System.ComponentModel.DataAnnotations.DataType)attribute.DataType;
            fieldTypes[property.Name] = dataType.ToString().ToLowerInvariant();
        }
        else
        {
            fieldTypes[property.Name] = null;
        }
    } }
<form id="mainForm" kendo-validator="true">
    <kendo-textbox for="UserPassword" type="@fieldTypes["UserPassword"]">
        <textbox-label content="@Html.DisplayNameFor(m=>m.UserPassword)" floating="true" />
    </kendo-textbox>
</form>
<script>
    $(document).ready(function () {
        var validator = $("#mainForm").data("kendoValidator");
    });
</script