分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > IT知识

.net+mvc,ueditor

发布时间:2023-09-06 01:15责任编辑:熊小新关键词:暂无标签

.net+mvc的百度编辑器ueditor

一、下载百度编辑器:http://ueditor.baidu.com/website/download.html

  选择.net版本

二、解压后在mvc项目中创建ueditor文件夹,并把解压内容复制到里面

  

三、编辑视图

  1、控制器内容

        [HttpGet]
        public ActionResult Index(int a=1)
        {
            return View();
        }
        [HttpPost]
        [ValidateInput(false)]//关闭验证,允许html格式的内容传说到控制器
        public ActionResult Index()
        {
            var content = Request.Form["content"];
            return View();
        }

        2、body内容

  <form action="Index" method="post">
            <!-- 加载编辑器的容器 -->
            <%--<script id="editor" name="editor" type="text/plain">--%>
            <script id="container" name="content" type="text/plain">
                这里写你的初始化内容
            </script>
            <!-- 配置文件 -->
            <script type="text/javascript" src="ueditor.config.js"></script>
            <!-- 编辑器源码文件 -->
            <script type="text/javascript" src="ueditor.all.js"></script>
            <input type="submit" value="提交" />
        </form>

3、script内容

    <script type="text/javascript">
        var editor = new baidu.editor.ui.Editor({
            UEDITOR_HOME_URL: ‘/Ueditor/‘,//配置编辑器路径
            iframeCssUrl: ‘/Ueditor/themes/iframe.css‘,//样式路径
            initialContent: ‘欢迎使用ueditor‘,//初始化编辑器内容
            autoHeightEnabled: true,//高度自动增长
            minFrameHeight: 500//最小高度
        });
        editor.render(‘container‘);
    </script>

四、关闭验证web.config

    <system.web>
           <httpRuntime targetFramework="4.5" requestValidationMode="2.0"/>

   </system.web>

.net+mvc,ueditor

原文地址:http://www.cnblogs.com/wskxy/p/7622788.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved