I am trying to create a page which has Telerik Editor control. Use can create email templates using this screen. when I have put this Control in side @Html.BeginForm it works. I mean then i am able to get the value in my Controller .
When I create the form tag and put this Editor inside that tag, it does not work. The value comes as null in my controller.
WORK :-
@using (Html.BeginForm("Create", "Template", FormMethod.Post, new { @class = "ajax-form" }))
{
<div class="file-contents">
<div class="editor-label">
@Html.LabelFor(model => model.Contents)
</div>
<div class="editor-field">
@(Html.Telerik().EditorFor(model => model.Contents)
.HtmlAttributes(new { style = "width: 600px; height: 300px;" })
.Encode(false)
)
@Html.ValidationMessageFor(model => model.Contents)
</div>
</div>
}
Does not work.
<form dojoType="dijit.form.Form" id="createTemplateForm" jsId="createTemplateForm" encType="multipart/form-data" action="@Url.Action("Create", "Template")" method="POST"> <div class="file-contents">
<div class="editor-label">
@Html.LabelFor(model => model.Contents)
</div>
<div class="editor-field">
@(Html.Telerik().EditorFor(model => model.Contents)
.HtmlAttributes(new { style = "width: 600px; height: 300px;" })
.Encode(false)
)
@Html.ValidationMessageFor(model => model.Contents)
</div>
</div>
</form>
Any idea why is this happening? Please let me know.
Thanks.
In order for the two to match up, the “name” attribute has to be set correctly.
Make sure on the version with the form tag, the “name” attribute is set correctly on the Telerik input.
If it is not, you can add it by passing an object of html settings (should be one of the overloads)