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

EditorFor binding not working on form submit

1 Answer 763 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Karl
Top achievements
Rank 1
Karl asked on 21 Aug 2015, 08:29 AM

The control manages to bind and show the value from my model, but when I submit the form, the model in my controller does not show the updated value from the editor.

 

I have tried using a normal @Html.EditorFor() and this works as expected. (ie I see the updated value)

 

 @model GeneralDisclosureEntity

@using (Html.BeginForm("GeneralDisclosureTextUpdate", "DataManagement", FormMethod.Post, new { enctype = "multipart/form-data" }))
{    

    <div hidden="hidden">
        @Html.EditorForModel()
    </div>
    
            
    @(Html.Kendo().EditorFor(m => m.HTML)
          .Name("Content")
          .HtmlAttributes(new { style = "width:100%;height:440px" })
          .Encode(false)
          .Tools(t => t.Clear()
              .Bold()
              .Italic()
              .Underline()
              .Strikethrough()
              .JustifyLeft()
              .JustifyCenter()
              .JustifyRight()
              .JustifyFull()
              .InsertUnorderedList()
              .InsertOrderedList()
              .Indent()
              .Outdent())
    )

    <br />

  <button id="btnSubmit3" type="submit" style="float:right")>Save Text</button>
    
}

1 Answer, 1 is accepted

Sort by
1
Alexander Popov
Telerik team
answered on 25 Aug 2015, 07:58 AM
Hello Karl,

I've noticed that the name of the widget is explicitly specified as "Content". This might cause issues with the model binding on the server-side, as the Controller method probably expects a field named "HTML". Generally speaking, all For helpers (e.g EditorFor, ComboBoxFor and etc) automatically assign a name to the widget, so manually doing that is not necessary. Removing the Name method from the widget's configuration should solve the issue.

Regards,
Alexander Popov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Editor
Asked by
Karl
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or