zoukankan      html  css  js  c++  java
  • MVC4 使用 ckfinder+ckeditor编辑器

    配置
    ckfinder for asp.net 版本下载地址
     http://cksource.com/ckfinder/download
    ckeditor下载地址 http://ckeditor.com/download  

    config.ascx

    public override bool CheckAuthentication()
    {
    
    
     
    
    return true; 设置为true
    }
    

      

    ckeditor config.js 新增

    config.filebrowserBrowseUrl = '/ckfinder/ckfinder.html'; //不要写成"~/ckfinder/..."或者"/ckfinder/..." 
    config.filebrowserImageBrowseUrl = '/ckfinder/ckfinder.html?Type=Images';
    config.filebrowserFlashBrowseUrl = '/ckfinder/ckfinder.html?Type=Flash';
    config.filebrowserUploadUrl = '/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Files';
    config.filebrowserImageUploadUrl = '/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Images';
    config.filebrowserFlashUploadUrl = '/ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Flash';
    config.filebrowserWindowWidth = '800'; //“浏览服务器”弹出框的size设置 config.filebrowserWindowHeight = '500'; }
    

      

    View

    引用JS

    <script src="../../ckeditor/ckeditor.js"></script>
    <script src="../../ckfinder/ckfinder.js"></script>
    <script src="../../Scripts/jquery-1.8.2.js"></script>
    
    
    
    <div>
    <textarea name="TextArea1" cols="20" rows="2" class="ckeditor">@ViewBag.content</textarea>//新增
    <textarea name="TextArea1" cols="20" rows="2" class="ckeditor">@Model.Content</textarea>//编辑
    
    </div>
    <p>
    <input type="submit" value="添加" />
    </p>
    

      

    <script type="text/javascript">
    $(function () {
    var editor = CKEDITOR.replace("TextArea1", { "toolbar": "Basic" }); //显示编辑器
    CKEDITOR.replace('TextArea1');
    var editor = CKEDITOR.replace('TextArea1');
    CKFinder.SetupCKEditor(editor, '/ckfinder/');
    
    })
    </script>
    

      

    Controller

    [HttpPost]
    [ValidateInput(false)] //设置避免出现 检测到有潜在危险的 Request.Form 
    
    
    public ActionResult Edit(int id, FormCollection collection)
    {
    var content = collection["TextArea1"];
    var userinfo = db.userinfo.Find(id);
    userinfo.img = img;
    db.SaveChanges();return RedirectToAction("Index");
    
    }
    
     
    

      

  • 相关阅读:
    解决FileReader读取文件乱码问题
    comparable 与 comparator
    JavaScript添加水印
    mybatis里oracle与MySQL的insert_update
    关于回车换行
    solr创建collection
    hbase相关配置说明
    java基础(十一)--- IO
    java基础(十)--- 异常
    c++中的vector原理
  • 原文地址:https://www.cnblogs.com/zhang9418hn/p/3173859.html
Copyright © 2011-2022 走看看