FCKEditor现在已经到2.3版了。对于ASP.NET的开发者来说,FCKEditor2.3版确实是一个好东西。它增加了对ASP.NET的支持。
下面是我在测试时的一些笔记和心得。
第一步、安装
FCKEditor2.3的安装过程非常简单,其实就是解压。关键是选择一个好的解压目录。通常建议将FCKEditor2.3解压到工程的根目录下。
具体的安装过程请参考wiki手册。
注意:现在的版本在ASP.NET环境下,显示图片有Bug。在编译FCKEditor_NET工程之前,先修改一下"FileBrowserConnector.cs"的"CreateBaseXml"函数:
private XmlNode CreateBaseXml( XmlDocument xml, string command, string resourceType, string currentFolder )
{
// Create the XML document header.
xml.AppendChild( xml.CreateXmlDeclaration( "1.0", "utf-8", null ) ) ;
// Create the main "Connector" node.
XmlNode oConnectorNode = XmlUtil.AppendElement( xml, "Connector" ) ;
XmlUtil.SetAttribute( oConnectorNode, "command", command ) ;
XmlUtil.SetAttribute( oConnectorNode, "resourceType", resourceType ) ;
// Add the current folder node.
XmlNode oCurrentNode = XmlUtil.AppendElement( oConnectorNode, "CurrentFolder" ) ;
XmlUtil.SetAttribute( oCurrentNode, "path", currentFolder ) ;
string url = GetUrlFromPath(resourceType, currentFolder);
if (url.StartsWith("~/"))
{
url = url.Substring(2);
}
else if (url.StartsWith("/"))
{
url = url.Substring(1);
}
XmlUtil.SetAttribute( oCurrentNode, "url", url ) ;
return oConnectorNode ;
}
{
// Create the XML document header.
xml.AppendChild( xml.CreateXmlDeclaration( "1.0", "utf-8", null ) ) ;
// Create the main "Connector" node.
XmlNode oConnectorNode = XmlUtil.AppendElement( xml, "Connector" ) ;
XmlUtil.SetAttribute( oConnectorNode, "command", command ) ;
XmlUtil.SetAttribute( oConnectorNode, "resourceType", resourceType ) ;
// Add the current folder node.
XmlNode oCurrentNode = XmlUtil.AppendElement( oConnectorNode, "CurrentFolder" ) ;
XmlUtil.SetAttribute( oCurrentNode, "path", currentFolder ) ;
string url = GetUrlFromPath(resourceType, currentFolder);
if (url.StartsWith("~/"))
{
url = url.Substring(2);
}
else if (url.StartsWith("/"))
{
url = url.Substring(1);
}
XmlUtil.SetAttribute( oCurrentNode, "url", url ) ;
return oConnectorNode ;
}
第二步、配置ASP.NET WetSite
配置可以分为以下几步:
- 添加引用
- 向工具栏中添加项目
- 设置Web.setting,增加以下设置:
<appSettings>
<add key="FCKeditor:UserFilesPath" value="~/UserFiles/"/>
</appSettings>
第三步、使用FCKeditor
接下来只需要在页面上添加FCKeditor控件就可以了。记得在控检属性中加上BasePath属性,如下所示:
<FCKeditorV2:FCKeditor ID="FCKeditor1" BasePath="~/FCKeditor/" runat="server">
</FCKeditorV2:FCKeditor>
由于默认情况下,ASP.NET在提交数据时会验证数据是否有潜在危险,所以要设置页面的ValidateRequest为false。
ASP.NET的设定,参考wiki手册
浙公网安备 33010602011771号