与DropDownList的错误时的CKEditor也在页面上使用 [英] Error with DropDownList when CKEditor is also in use on page
问题描述
我有工作就好了一个DropDownList,但是当我有添加 CKEditor的
(CKEditor的标准4.5.7),以韩德尔 EditorFor
帮助我得到这个错误:
这有钥匙'OccupationId的ViewData的产品类型
System.Int32,但必须是类型为IEnumerable的
块引用>删除
CKEDITOR
解决这个错误,但我确实需要它,相关code(从视图)< DIV CLASS =表单组>
@ Html.LabelFor(型号=> model.rev.ReviewBody,htmlAttributes:新{@class =控制标签COL-MD-2})
< DIV CLASS =COL-MD-10>
@ Html.EditorFor(型号=> model.rev.ReviewBody,新{htmlAttributes = {新@class =表格控,@id =RevBEditor}})
@ Html.ValidationMessageFor(型号=> model.rev.ReviewBody,新{@class =TEXT-危险})
< / DIV>
< / DIV> < DIV CLASS =表单组>
@ Html.LabelFor(型号=> model.sub.Occupation.OccupationDecription,职业,htmlAttributes:新{@class =控制标签COL-MD-2})
< DIV CLASS =COL-MD-10>
@ Html.DropDownList(OccupationId,空,htmlAttributes:新{@class =})
@ Html.ValidationMessageFor(型号=> model.OccupationId,新{@class =TEXT-危险})
< / DIV>
< / DIV><脚本SRC =〜/脚本/ CKEditor的/ ckeditor.js>< / SCRIPT>
<脚本类型=文/ JavaScript的> CKEDITOR.replace('RevBEditor'); < / SCRIPT>
解决方案这是因为CKEditor的不是,那是发生是因为你没有给一个数据源地掉了下来。
I have a dropdownlist that is working just fine, but when I have add a
CKEditor
(ckeditor-standard 4.5.7) to handelEditorFor
helper I'm getting this error:The ViewData item that has the key 'OccupationId' is of type 'System.Int32' but must be of type 'IEnumerable'.
Removing the
CkEditor
solve this error but I do need it, relevant code (from view)<div class="form-group"> @Html.LabelFor(model => model.rev.ReviewBody, htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.rev.ReviewBody, new { htmlAttributes = new { @class = "form-control", @id = "RevBEditor" } }) @Html.ValidationMessageFor(model => model.rev.ReviewBody, "", new { @class = "text-danger" }) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.sub.Occupation.OccupationDecription, "Occupation", htmlAttributes: new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.DropDownList("OccupationId", null, htmlAttributes: new { @class = "" }) @Html.ValidationMessageFor(model => model.OccupationId, "", new { @class = "text-danger" }) </div> </div><script src="~/Scripts/ckeditor/ckeditor.js"></script> <script type="text/javascript"> CKEDITOR.replace('RevBEditor'); </script>
解决方案That's not because of CKEditor, that is happening because you did not give a data source to drop down
这篇关于与DropDownList的错误时的CKEditor也在页面上使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!