This is a migrated thread and some comments may be shown as answers.

How do I set the value to a model value in a template?

1 Answer 454 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 02 Apr 2015, 07:28 PM
I have a popup editor template with an editor in it and I'm trying to figure out how to set the value to the model field value. I have :

@(Html.Kendo().Editor()
      .Name("Body")
      .HtmlAttributes(new { style = "width: 590px;height:440px" })
      .Value(@Model.Body)
)

But that does not work. Anyone know the answer?

1 Answer, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 06 Apr 2015, 08:50 AM
Hello Daniel,

Basically, this happens through an MVVM value binding, which is generated according to the widget's name. I would suggest using a strongly typed View and the EditorFor helper, which assigns a name matching the used field. For example: 
@model MyModel
 
@(Html.Kendo().EditorFor(m=>m.SomeTextField)
      .HtmlAttributes(new { style = "width: 590px;height:440px" })
)

Regards,
Alexander Popov
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
Editor
Asked by
Daniel
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or