The data attributes are not rendered for the DropDownlist when bound to Model in Razor Pages.
View:
@page
@model TelerikAspNetCoreApp12.Pages.IndexModel
<form>
@(Html.Kendo().DropDownList()
.Name("fabric")
.OptionLabel("Select...")
.DataTextField("Text")
.DataValueField("Value")
.BindTo(Model.Data)
.Filter("contains")
)
<input type="submit" />
</form>
Back end:
namespace TelerikAspNetCoreApp12.Pages
{
public class IndexModel : Microsoft.AspNetCore.Mvc.RazorPages.PageModel
{
public List<TestModel> Data { get; set; } = new List<TestModel>();
public void OnGet()
{
for (int i = 1; i <= 100; i++)
{
Data.Add(new TestModel() { Text = "product" + i, Value = i.ToString() });
}
}
}
}
Model:
namespace TelerikAspNetCoreApp12.Models
{
public class TestModel
{
[Required(ErrorMessage = "Please select")]
public string Text { get; set; }
public string Value { get; set; }
}
}
Inspect the input field for the DropDownList. It does not have data-val and data-val-required attributes.
The data attributes are not being rendered.
The data attributes should be rendered.