ASP.NET MVC Telerik 编辑器不适用于表单标签
我正在尝试创建一个具有 Telerik Editor 控件的页面。用户可以使用此屏幕创建电子邮件模板。当我将此控件放在 @Html.BeginForm 旁边时,它就可以工作了。我的意思是这样我就能够获取 Controller 中的值。 当我创建表单标签并将此编辑器放入该标签内时,它不起作用。该值在我的控制器中为空。
工作:-
@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>
}
不工作。
<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>
知道为什么会发生这种情况吗?请告诉我。
谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了使两者匹配,必须正确设置“name”属性。
确保在带有表单标签的版本上,Telerik 输入上的“name”属性设置正确。
如果不是,您可以通过传递 html 设置的对象来添加它(应该是重载之一)
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)