The most experience I have in server side languages is copy/paste so i'm sort of out of my league here.
I'm trying to use FCKeditor/asp to edit a .htm document with the basic editor that will be loaded into a datafield in flash.
I was able to get the flash part working, and I found a script that writes the data from the editor to a text document, but I can't figure out how to get the text/html document to load into the FCKeditor.
I've done some googling/searchign and i've found ways to do it with databases and a variable being pulled from those files, but is there a way to just have it load an entire .txt/.htm document as the value for the editor via asp?
Thanks.
I'm trying to use FCKeditor/asp to edit a .htm document with the basic editor that will be loaded into a datafield in flash.
I was able to get the flash part working, and I found a script that writes the data from the editor to a text document, but I can't figure out how to get the text/html document to load into the FCKeditor.
I've done some googling/searchign and i've found ways to do it with databases and a variable being pulled from those files, but is there a way to just have it load an entire .txt/.htm document as the value for the editor via asp?
Thanks.
RE: stupid simple (i hope) asp question.
StreamReader sr = null;
try
{
sr = new StreamReader(path);
string text = sr.ReadToEnd();
return text
}
catch (Exception ex)
{
return null;
}
finally
{
if (sr != null)
{
sr.Close();
}
}
where path is the location of the file you want to open. The language here is C# but most languages have something similar.
RE: stupid simple (i hope) asp question.
RE: stupid simple (i hope) asp question.
well what I meant was that if I change oFCKeditor.Value = "Put this text into the content editor" the FCKeditor loads fine.
If i make f a variable and open the textfile blog.txt as the variable f, I get the error I pasted above.
If you want to look at the code I have it zipped here: http://www.wsiprojects.com/text/fckeditor/blog.zip
The fckeditor.asp page would go into the /fckeditor/ folder and the other three files are pointed to /fckeditor/_samples/asp
Thanks for your help on this.
i'm really not sure what I need to do to get it working.
RE: stupid simple (i hope) asp question.
dim fs, f
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile(Server.MapPath("blog.txt"))
oFCKeditor.Value = f
oFCKeditor.Create "FCKeditor1"
when I pull the file from the text document and write the variable, it will display the text, but when I try doing this with the FCKeditor I get the following error:
Microsoft VBScript runtime error '800a01b6'
Object doesn't support this property or method: 'sValue'
/test/fckeditor/fckeditor.asp, line 72
If I remove the f variable and make it something else, it works fine.
Any Ideas?
RE: stupid simple (i hope) asp question.
oFCKeditor.Value = f
f is an Object, not a string as required by the FCKEditor class!
Set f=fs.OpenTextFile(Server.MapPath("blog.txt"))
oFCKeditor.Value = f.ReadALL
^ this should do it... don't forget to close the file and release the objects after this block.
Not trying to be condescending but really it's a good idea to learn the language (vbscript in this case) or you're just asking for trouble with security and otherwise. Especially when you're working with the file system object you are potentially exposing the server to the world, in this case if you're hard coding the file path and name you should be ok, but just beware.
Google the FileSystemObject there are plenty of resources available to you.