信息发布webpart——网页编辑器应用攻略


在一个MOSS项目中,我需要另行开发信息发布系统。信息发布系统关键的内容就是编辑器。

  MOSS中使用RTF编辑器,如果我们能够在webpart的使用该编辑器,当然最好。我不知道如何将RTF编辑器应用到WEBPART中,由于项目时间问题,我没在这上面多耗时间,决定采用其它的编辑器。

  我们对编辑器的需求是:

  能够进行简单的编辑工作;

  能够上传图片到服务器并插入图片;

  需求非常简单,于是我找到了好几个业界反应比较热烈的编辑器。

  WebHTMLEditor:这是lion的编辑器,非常不错,能够支持设计模式开发,能够很容易的应用在WEBPART中,在以前的项目中,我采用过该编辑器。但由于该编辑器是收费的,所以今次我决定暂不采纳。

  eWebEditor:这个也非常好,在非MOSS项目中我也用过,但由于上传图片功能未开放,也只好放弃了。听有人说,上传图片功能是有的,但是我一直没找到有上传图功能的版本。如果哪位有,希望能够共享一下。

  FreeTextBox:这个我也用过,这个也是没有图片上传功能的。

  FCKeditor:这个没用过,据说不错,所以今次就拿来研究一下。最终采用了该编辑器。

  使用过程如下:

  1.下载了FCKeditor.Net_2.6.3.zip及FCKeditor_2.6.3.zip(下载地址忘了,非常好找的)

  从FCKeditor.Net_2.6.3.zip中取到FredCK.FCKeditorV2.dll.

  从FCKeditor_2.6.3.zip中取到fckeditor

  2.创建webpart工程

  引用FredCK.FCKeditorV2.dll

private FredCK.FCKeditorV2.FCKeditor fckContent = new FredCK.FCKeditorV2.FCKeditor();

protected override void CreateChildControls()

{

fckContent.BasePath = "/_layouts/fckeditor/";      
this.Controls.Add(this.fckContent);

}

protected override void Render(HtmlTextWriter writer)
{
fckContent.RenderControl(writer); 

}

  好了,webpart做完了。

  3。将fckeditor文件夹及其所有内容拷贝到moss站点的_layouts目录(C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions12templatelayouts)

  4.在fckeditor中添加文件夹userfiles.开放该文件夹的可写权限给需上传图片的用户。

  5。更改文件fckconfig.js.(找到相应的行,值改为我如下所示)

FCKConfig.DefaultLanguage = 'zh-cn' ;

var _FileBrowserLanguage= 'aspx' ;// asp | aspx | cfm | lasso | perl | php | py
var _QuickUploadLanguage= 'aspx' ;// asp | aspx | cfm | lasso | perl | php | py

  6。更改文件fckeditoreditorfilemanagerconnectorsaspxconfig.ascx

private bool CheckAuthentication()
{

    return true;
}

  再将public override void SetConfig()中的

  UserFilesPath = "/_layouts/fckeditor/userfiles/";

  保存。

  7.将webpart部署到moss中试试。行了不?

  如果不行。检查两个路径BasePath 及UserFilesPath 正确否?注意必须是相对路径

本文作者:
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3