In the official default version, FCKeditor does not support Asp.net (there is no interface for Asp.net to call), but there is an interface for ASP to call. According to FCKeditor. ASP file is rewritten with C. net interface. For more information, see.
<Script language = "C #" runat = "server">
Public class FCKeditor
{
Private string sbasepath;
Private string sinstancename;
Private string swidth;
Private string sheight;
Private string stoolbarset;
Private string svalue;
Private arraylist oconfig;
Public FCKeditor ()
{
Sbasepath = "/admin/FCKeditor /";
Swidth = "100% ";
Sheight = "200 ";
Stoolbarset = "default ";
Svalue = "";
Oconfig = new arraylist ();
}
Public String basepath
{
Get {return sbasepath ;}
Set {sbasepath = value ;}
}
Public String InstanceName
{
Get {return sinstancename ;}
Set {sinstancename = value ;}
}
Public String width
{
Get {return swidth ;}
Set {swidth = value ;}
}
Public string height
{
Get {return sheight ;}
Set {sheight = value ;}
}
Public String toolbarset
{
Get {return stoolbarset ;}
Set {stoolbarset = value ;}
}
Public String Value
{
Get {return svalue ;}
Set {svalue = value ;}
}
Public void config (string configkey, string configvalue)
{
Oconfig. Add (New dictionaryentry (configkey, configvalue ));
}
Public void create (string InstanceName)
{
Httpcontext. Current. response. Write ("<div> ");
If (iscompatible ())
{
String sfile = "";
String slink = "";
If (httpcontext. Current. request ["fcksource"] = "true") {sfile = "fckeditor.original.html ";}
Else {sfile = "fckeditor.html ";}
Slink = sbasepath + "Editor/" + sfile + "? InstanceName = "+ InstanceName;
If (stoolbarset! = "") Slink = slink + "& toolbar =" + stoolbarset;
httpcontext. current. response. write ("");
httpcontext. current. response. write (" ");
httpcontext. current. respons E. write (" ");
}< br> else
{< br> string swidthcss = "";
string sheightcss = "";
If (swidth. indexof ('% ')! =-1) {swidthcss = swidth ;}< br> else {swidthcss = swidth + "PX" ;}
If (sheight. indexof ('% ')! =-1) {sheightcss = sheight ;}
Else {sheightcss = sheight + "PX ";}
Httpcontext. current. response. write ("<textarea name = '" + InstanceName + "'rows = '4' Cols = '40' style = 'width:" + swidthcss + "; height: "+ sheightcss +" '> "+ httpcontext. current. server. htmlencode (svalue) + "</textarea> ");
}
Httpcontext. Current. response. Write ("</div> ");
}
private bool iscompatible ()
{< br> string sagent = httpcontext. current. request. useragent;
double iversion;
bool iiscompatible = false;
If (sagent. indexof ("MSIE ")! =-1 &
sagent. indexof ("Mac") =-1 &
sagent. indexof ("Opera") =-1)
{< br> try {iversion = convert. todouble (sagent. substring (sagent. indexof ("MSIE") + 4,4 ). trim () ;}< br> catch {iversion = 0 ;}< br> iiscompatible = (iversion >=5.5 );
}< br> else
{iiscompatible = false ;}< br> return iiscompatible;
}
Private string getconfigfieldstring ()
{
String sparams = "";
Bool bfirst = true;
Foreach (dictionaryentry de in oconfig)
{
If (bfirst = false) {sparams = sparams + "&";}
Else {bfirst = false ;}
Sparams = sparams + encodeconfig (De. Key. tostring () + "=" + encodeconfig (De. value. tostring ());
}
Return sparams;
}
Private string encodeconfig (string valuetoencode)
{
String sencodeconfig;
Sencodeconfig = valuetoencode. Replace ("&", "% 26 ");
Sencodeconfig = sencodeconfig. Replace ("=", "% 3d ");
Sencodeconfig = sencodeconfig. Replace ("'", "% 22 ");
Return sencodeconfig;
}
}
</SCRIPT>
Usage:
<%
String sbasepath = request. servervariables ["path_info"];
FCKeditor ofckeditor = new FCKeditor ();
Ofckeditor. basepath = "./FCKeditor /";
Ofckeditor. width = "100% ";
Ofckeditor. Height = "400 ";
Ofckeditor. toolbarset = "Basic ";
Ofckeditor. Create ("body ");
%>
In addition, this editor uses Asp.net to upload and browse files.ProgramNo, but you can set ASP to the default scripting language in the configuration file. Generally, servers that support Asp.net support ASP, however, the Asp.net program cannot directly call ASP classes, so I wrote this interface.