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");
    
    }
    
     
    

      

  • 相关阅读:
    Liunx命令集
    Jenkins,tomcat和jdk安装步骤
    《九悦学车》和《忠金融·惠生活》BUG表
    2020年12月17日总结
    思维导图加上测试用例
    2020年12月15日总结
    双肩包、椅子和电梯的测试用例(测试题)
    fastadmin 前台关联搜索
    composer安装阿里云短信
    php 生成订单号
  • 原文地址:https://www.cnblogs.com/zhang9418hn/p/3173859.html
Copyright © 2011-2022 走看看