C# RichTextEditor不适用于ASP.NET MVC5中的多个字段

C# RichTextEditor不适用于ASP.NET MVC5中的多个字段,c#,asp.net,asp.net-mvc,asp.net-mvc-5,tinymce,C#,Asp.net,Asp.net Mvc,Asp.net Mvc 5,Tinymce,我想在MVC5中创建一个类似下图的表单 您将看到它有两个用于英语和阿拉伯语的富编辑文本字段,我随后添加了这些富文本字段 但当我把它像下面的图片,一个富文本字段不工作 这是视图页面中的相关代码段 <div class="form-group"> @Html.LabelFor(model => model.ProductAbstractEn, htmlAttributes: new { @class = "control-label col-md-2" })

我想在MVC5中创建一个类似下图的表单

您将看到它有两个用于英语和阿拉伯语的富编辑文本字段,我随后添加了这些富文本字段

但当我把它像下面的图片,一个富文本字段不工作

这是视图页面中的相关代码段

    <div class="form-group">
    @Html.LabelFor(model => model.ProductAbstractEn, htmlAttributes: new { @class = "control-label col-md-2" })
    <div class="col-md-10">
        @Html.EditorFor(model => model.ProductAbstractEn, new { htmlAttributes = new { @class = "form-control" } })
        @Html.ValidationMessageFor(model => model.ProductAbstractEn, "", new { @class = "text-danger" })
    </div>
</div>

<div class="form-group">
    @Html.LabelFor(model => model.ProductAbstractAr, htmlAttributes: new { @class = "control-label col-md-2" })
    <div class="col-md-10">
        @Html.EditorFor(model => model.ProductAbstractAr, new { htmlAttributes = new { @class = "form-control" } })
        @Html.ValidationMessageFor(model => model.ProductAbstractAr, "", new { @class = "text-danger" })
    </div>
</div>
你能告诉我如何使这两个领域可行吗

编辑的代码tinymce\u full\u compressed.cshtml

  <script src="@Url.Content("~/Scripts/tinymce/tiny_mce.js")" type="text/javascript"></script>

<script type="text/javascript">
(function(){tinyMCE.init({mode:"exact",elements:"@ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty)",theme:"advanced",height:"500",width:"790",verify_html:false,plugins:"pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave",theme_advanced_buttons1:"save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",theme_advanced_buttons2:"cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",theme_advanced_buttons3:"tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",theme_advanced_buttons4:"insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft,codehighlighting,netadvimage",theme_advanced_toolbar_location:"top",theme_advanced_toolbar_align:"left",theme_advanced_statusbar_location:"bottom",theme_advanced_resizing:false,content_css:"@Url.Content("~/Scripts/tinymce.3.4.5/css/content.css")",convert_urls:false,template_external_list_url:"lists/template_list.js",external_link_list_url:"lists/link_list.js",external_image_list_url:"lists/image_list.js",media_external_list_url:"lists/media_list.js",})})();
</script>

@Html.TextArea(string.Empty, /* Name suffix */
    ViewData.TemplateInfo.FormattedModelValue /* Initial value */
)

(function(){tinyMCE.init({mode:“exact”,元素:“@ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty)”,主题:“高级”,高度:“500”,宽度:“790”,验证html:false,插件:“分页符、样式、图层、表格、保存、advhr、advimage、advlink、情感、iSpell、inlinepopups、insertdatetime、预览、媒体、搜索替换、打印、上下文菜单、粘贴、方向性、全屏、不可编辑、可视光标、不可中断、xhtmlxtras、模板、字数、advlist、自动保存”,主题\高级\按钮1:”保存、新建文档、|、粗体、斜体、下划线、删除线、|、左对齐、居中对齐、右对齐、全对齐、样式选择、格式选择、字体选择、字体选择、字体大小选择”,主题\高级\按钮2:“剪切、复制、粘贴、粘贴文本、粘贴文字、搜索、替换、粘贴时间、布利斯特、numlist、删除、缩进、块引号、撤消、重做、链接、取消链接、锚定、图像、清理、帮助、代码、插入日期、插入时间、预览、预览、前景色、背景色”,主题“高级”按钮3:“tablecontrols、|、hr、removeformat、visualaid、|、sub、sup、|、charmap、情感、Ispell、media、advhr、|、print、|、ltr、rtl、|、全屏)、theme_advanced|按钮4:“插入层、向前移动、向后移动、绝对、|、styleprops、|、引用、缩写、缩写、del、ins、attribs、|、visualchars、非中断、模板、分页符、还原、代码高亮显示、netadvimage”,theme\u advanced\u toolbar\u location:“top”,theme\u advanced\u toolbar\u align:“left”,theme\u statusbar\u location:“bottom”,theme\u advanced\u resizing:false,content\u css:“@Url.content”(~/Scripts/tinymce.3.4.5/css/content.css”),“convert\u Url:false,template\u external\u list\u Url:“list/template\u list.js”,external\u list\u Url:“list/link\u list.js”,外部图片列表(url:“lists/image_list.js”,媒体外部列表(url:“lists/media_list.js”,})}();
@Html.TextArea(string.Empty,/*名称后缀*/
ViewData.TemplateInfo.FormattedModelValue/*初始值*/
)

我从您的教程中安装了NuGet软件包,下面是我的想法

在模板中(
tinymce\u full\u compressed
tinymce\u full
)包含以下字符串:

<script src="@Url.Content("~/Scripts/tinymce/tiny_mce.js")" type="text/javascript"></script>
根据本守则:

$(document).ready(function () { //To make sure that DOM is loaded
    $('#@ViewData.TemplateInfo.GetFullHtmlFieldId(string.Empty)').tinymce({ //changed selector for initialization

                mode: "exact",
                // Location of TinyMCE script
                script_url: '@Url.Content("~/Scripts/tinymce/tiny_mce.js")', //this line should fix your problem in script adding
            ... //here more optins, don't touch them
        }); 
})();

显示将插件连接到textarea元素的脚本,并显示
tinymce\u full\u compressed.cshtml
@StephenMuecke我已经更新了代码您的问题是您的部分中有脚本-部分不应该有脚本(加载多个副本时,一个副本可以擦除另一个副本)。在主脚本中附加插件我需要在“添加新产品”查看页面中添加上述脚本吗?thnks很多,我在“tinymce\u full\u compressed.cshtml”中做了您的更改,但这两个都不是working@ChathzF12模式下的浏览器是什么?有什么错误吗?我是firebug控制台的新手,我如何识别F12的任何错误,似乎我没有任何重大错误error@Chathz我使用的是chrome而不是firefox,在chrome中有
控制台
选项卡,其中包含所有脚本错误。如果你没有任何错误,可能是选择器将你的插件添加到
input
错误,你确定你会像我在本例中写的那样进行更改吗?@是的,现在我的'tinymce\u full\u compressed.cshtml'正是这样,但我没有更改“tinymce\u full.cshtml”
(function(){ 

    tinyMCE.init({

        // General options
        mode: "exact",
        elements: "@ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty)",
        ... //here more optins, don't touch them
    });

})();
$(document).ready(function () { //To make sure that DOM is loaded
    $('#@ViewData.TemplateInfo.GetFullHtmlFieldId(string.Empty)').tinymce({ //changed selector for initialization

                mode: "exact",
                // Location of TinyMCE script
                script_url: '@Url.Content("~/Scripts/tinymce/tiny_mce.js")', //this line should fix your problem in script adding
            ... //here more optins, don't touch them
        }); 
})();