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

2 posts, 0 answers
  1. Daniel
    Daniel avatar
    3 posts
    Member since:
    Sep 2014

    Posted 02 Apr 2015 Link to this post

    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?
  2. Alexander Popov
    Admin
    Alexander Popov avatar
    1416 posts

    Posted 06 Apr 2015 Link to this post

    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.

     
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top