我正在尝试在网站上输入两个HTML文本,我的模型在这两个元素上具有相同的属性,但是当我进入页面时,只有其中一个呈现HTMl输入,我做错了什么?这是代码:
模型类
namespace RoyalHoliday.Models
{
[Table("Contacts")]
public class Contact
{
[Key]
[JsonIgnore]
public int ContactId { get; set; }
[Display(Name = "Orden")]
public int Ordenado { get; set; }
[JsonIgnore]
[Display(Name = "Idioma")]
public int IdiomaId { get; set; }
[JsonIgnore]
public virtual Idioma Idioma { get; set; }
[DataType(DataType.Text)]
[StringLength(255, MinimumLength = 3)]
[Required()]
[Display(Name = "Título")]
public string Titulo { get; set; }
[DataType(DataType.MultilineText)]
[Required()]
[Display(Name = "Subtitulo")]
[AllowHtml]
public string Subtitulo { get; set; }
[DataType(DataType.MultilineText)]
[Required()]
[Display(Name = "Descripción")]
[AllowHtml]
public string Descripcion { get; set; }
}
}
这是cshtml
<div class="form-group">
@Html.LabelFor(model => model.Subtitulo, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Subtitulo, new { htmlAttributes = new { required = "required" } })
@Html.ValidationMessageFor(model => model.Subtitulo, "Campo de subtítulo es obligatorio", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Descripcion, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Descripcion, new { htmlAttributes = new { required = "required" } })
@Html.ValidationMessageFor(model => model.Descripcion, "La descripción es obligatoria", new { @class = "text-danger" })
</div>
</div>
这是渲染
编辑:以下是项目中的脚本列表
编辑2:以下是脚本:
<script type="text/javascript">
(function(){
$(function() {
$('#Descripcion').tinymce({
// Location of TinyMCE script
script_url: '/Scripts/tinymce/tiny_mce.js',
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 options
theme_advanced_buttons1: "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull",
theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,image,code",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : false,
// Example content CSS (should be your site CSS)
content_css : "~/Scripts/tinymce/css/content.css",
convert_urls : false,
// Drop lists for link/image/media/template dialogs
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>
你知道可能是什么吗?
答案 0 :(得分:0)
斯蒂芬指出我需要添加两个元素,这里是最后的脚本:
<script type="text/javascript">
(function(){
$(function() {
$('#Descripcion').tinymce({
// Location of TinyMCE script
script_url: '/Scripts/tinymce/tiny_mce.js',
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 options
theme_advanced_buttons1: "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull",
theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,image,code",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : false,
// Example content CSS (should be your site CSS)
content_css : "~/Scripts/tinymce/css/content.css",
convert_urls : false,
// Drop lists for link/image/media/template dialogs
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"
});
$('#Subtitulo').tinymce({
// Location of TinyMCE script
script_url: '/Scripts/tinymce/tiny_mce.js',
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 options
theme_advanced_buttons1: "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull",
theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,image,code",
theme_advanced_toolbar_location: "top",
theme_advanced_toolbar_align: "left",
theme_advanced_statusbar_location: "bottom",
theme_advanced_resizing: false,
// Example content CSS (should be your site CSS)
content_css: "~/Scripts/tinymce/css/content.css",
convert_urls: false,
// Drop lists for link/image/media/template dialogs
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>
渲染