asp.net mvc3 使用FckEditor 编辑内容

 

   在 razor 中 使用Fckeditor 编辑内容,需要引入js

    

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

  

   至于html编码

   

          <tr>
            <td>内容</td>
            <td>
                @Html.HiddenFor(model => model.Content)
                <script type="text/javascript">
                    
var f = new FCKeditor("FckContent""628""445");
                    f.Create();
                
</script>
                @Html.ValidationMessageFor(model => model.Content, "", new { @class = "red" })
            </td>
          </tr>

  

    要把Content中的数据传到后台,需要在提交时间中把值赋予@Html.HiddenFor(model => model.Content)    

<input type="image" src="/images/confirm.jpg" alt="确认" onclick="getEditorHTMLContents('FckContent')" />

   

    js 方法如下

   

function getEditorHTMLContents(EditorName) {
        var otxt = FCKeditorAPI.GetInstance(EditorName).GetHTML(true);
        if (otxt == '' || otxt == null) {
            return false;
        }
        else {
            $('input[id$="Content"]').val(otxt);
            return true;
        }
    }

    这样后台中传入的model中包含Content

    实现数据操作。

      

原文地址:https://www.cnblogs.com/lpe110/p/2387154.html