如何将剑道文本框控件绑定到其数据

本文关键字:绑定 控件 数据 文本 | 更新日期: 2023-09-27 17:56:33

我使用一些Kendo Telerik控件设计了一个视图。我不确定如何将他们的控件绑定到数据。

这个生成的脚手架方法有效:

@Html.EditorFor(model => model.surName, new { htmlAttributes = new { @class = "form-control" } })

如何绑定剑道文本框?

@(Html.Kendo().TextBox()
    .Name("fName") 
    .HtmlAttributes(new { placeholder = "First Name", required = "required", validationmessage="Enter First Name" })
)

如何将剑道文本框控件绑定到其数据

使用 Kendo().TextBoxFor 方法:

@(Html.Kendo().TextBoxFor(model => model.FirstName)
    .Name("fName")
    .HtmlAttributes(new { placeholder = "First Name", required = "required", validationmessage="Enter First Name" })
)