2017-09-29 14 views
0

웹 사이트에 두 개의 HTML 텍스트를 입력하려고 할 때 모델의 특성이 두 요소에서 동일하지만 페이지에 들어가면 그 중 하나만 HTMl 입력을 렌더링합니다. 내가 잘못하고있어? 여기에 스크립트의 목록의 다음하나 이상의 요소에 대해 HTMLML 속성 허용 MVC

enter image description here

편집 렌더링있어 여기 여기

모델 클래스

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> 

이고 다음은 코드는 피 roject

enter image description here

편집 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

그리고'[AllowHtml]'속성과 전혀 관련이 없습니다 –

+0

@StephenMuecke 저를 도와 줄 수 있습니까? 나는 스크립트를 추가했다. (나는이 프로젝트의 초기 개발자가 아니므로 2 개의 HTML 입력을 어떻게 넣을 수 있는지 모른다.) – magorich

답변

0

내가 TinyMCE에이 개 두 요소를 추가 할 필요, 여기에 최종 스크립트입니다 :

<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> 

그리고 당신은 부착 스크립트를 표시하지 않은

enter image description here

+1

하나의 스크립트 만 있으면됩니다 -'$ ('textarea'). tinymce ({...})'또는 요소에 클래스 이름을 사용하고이를 사용하십시오 (코드를 복제하는 점은 없습니다). 그리고 부수적으로'new {required = "required"}'를 제거하십시오 - jQuery 클라이언트 측 유효성 검사와 함께 작동하지 않습니다. –

+0

도움을 주셔서 감사합니다. – magorich