How do I bind the Kendo Textbox control to its data?

18.8k Views Asked by At

I have designed a view using some of the Kendo Telerik controls. I am not sure how to bind their controls to data.

This generated scaffolded method works :

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

How do I bind the Kendo Textbox?

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

There are 1 best solutions below

3
On BEST ANSWER

Use the Kendo().TextBoxFor method:

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