zoukankan      html  css  js  c++  java
  • Rich Text Editor for MVC

    在网站开发中难免会用到富文本编辑器,本文将介绍一款富文本编辑器(在线HTML编辑器) Rich Text Editor ,简要说明一下其在MVC中的使用。

    具体使用情况和下载地址请参考:http://www.richtexteditor.com/

    一、准备工作

    1.在上述网站中下载此编辑器的开发包,解压后会发现有几个文件夹,如图:

    我使用的是Asp.Net MVC4 版本,开发是c#,请大家选择适合自己的开发包。

    2.进入该文件(mvc4_cs_razor),把 richtexteditor 开发包文件夹复制到你的项目根目录下,并复制 bin 目录下的几个dll文件至你的项目bin文件夹下,如图:

    复制后,项目下就有了这些文件,如图:

    3. 添加对该编辑器DLL的引用(两个DLL:NetSpell.SpellChecker.dll 和 RichTextEditor.dll),如图:

    4.修改配置文件:

    IIS5,IIS6,IIS7 经典模式使用如下配置信息

    <configuration>
      <system.web>
        <httpModules>
          <add name="UploadModule" type="RTE.UploadModule,RichTextEditor"/>
         </httpModules>
      </system.web>
    </configuration> 

    IIS7 集成模式使用如下配置信息

    <configuration>
      <system.webServer>
        <modules>
          <add name="UploadModule" type="RTE.UploadModule,RichTextEditor"/>
        </modules>
      </system.webServer>
    </configuration> 
    二、在代码中如何使用

    做完上述准备工作后,就开始在代码中使用了

    1.发布新闻时

    [CheckLoginAttributer]
            public ActionResult Create()
            {
                Editor Editor1 = new Editor(System.Web.HttpContext.Current, "Content");
                Editor1.MvcInit();
                ViewBag.Editor = Editor1.MvcGetString();
    
                return View();
            }


    图解:

    2.编辑新闻时,新闻内容是怎么赋值的呢?

    //
            // GET: /News/Edit/5
            [CheckLoginAttributer]
            public ActionResult Edit(Guid id)
            {
                News news = db.News.Find(id);
                if (news == null)
                {
                    return HttpNotFound();
                }
    
                Editor Editor1 = new Editor(System.Web.HttpContext.Current, "Content");
                Editor1.Text = news.Content;
                Editor1.MvcInit();
                ViewBag.Editor = Editor1.MvcGetString();
    
                return View(news);
            }


    图解:

  • 相关阅读:
    The Hungarian algorithm Template
    用二进制方法求两个整数的最大公约数(GCD)
    <climits>头文件使用方法
    开大Stack的一个小技巧
    2014 HDU多校弟五场J题 【矩阵乘积】
    2014 HDU多校弟五场A题 【归并排序求逆序对】
    POJ 2449 求第K短路
    UVALive 6467 Strahler Order 拓扑排序
    POJ 1041 John's trip 无向图的【欧拉回路】路径输出
    Ural 1450 求最长路 SPFA
  • 原文地址:https://www.cnblogs.com/shaomenghao/p/3397725.html
Copyright © 2011-2022 走看看