FCKEditor and ASP.Net Fix


I'm not sure I'd call this a fix, more of an addition. Anyway, I've talked a couple of times about things that need to be changed with regard to the .Net Control that they have every once in a while. This time around it was more of an annoyance of mine. You see, I like to have a very well defined directory structure for my uploads. Images go in the images directory, etc. This works fine with FCK, as it puts images, media, flash files, etc. all in different folders. However, I like to take things further and divide things based on entries/pages. So for instance, I would prefer to have this post use a different directory for uploads and another post use a different directory. With FCK this is a pain to do but it's doable. You simply switch the FCKeditor:UserFilesPath application setting to the directory that you want. I find that annoying though. So instead I recommend the following function:

   1: [DefaultValue("/uploads/")]
   2: public string UploadPath
   3: {
   4:     get
   5:     {
   6:         object o = ViewState["UploadPath"];
   8:         if (o == null)
   9:             o = System.Configuration.ConfigurationSettings.AppSettings["FCKeditor:UserFilesPath"];
  11:         return (o == null ? "/uploads/" : (string)o);
  12:     }
  13:     set { ViewState["UploadPath"] = value; System.Configuration.ConfigurationSettings.AppSettings["FCKeditor:UserFilesPath"] = value; }
  14: }

Add that function to the FCKEditor class in the FCK Control (FCKeditor.cs file)... All that function does, is allows you to programmitcally change the FCK editor's upload location on the object itself. It's rather basic but has been annoying the heck out of me for a little bit now. In theory they're working on improving this but in the mean time, you might as well just add the function above. Anyway, it might not be the most useful bit of code but it annoyed me to no end for a day or two so I figured I'd share. So try it out, leave feedback, and happy coding.