Çàïóñêàåì FCKeditor ïîä ASP.NET MVC

Èñòî÷íèê: progblog

 

Äëÿ ðàáîòû ïîíàäîáÿòñÿ:

  1. FCKeditor 2.6.4
  2. FCKeditor.Net

Äàëåå ïðîñòî äîáàâëÿåì â ïðîåêò ïàïêó "fck" ñî ñêðèïòàìè. È ïîäêëþ÷àåì fckeditor.js â ìàñòåð ñòðàíèöå.

  1. <script src="<%=ResolveUrl("~/Scripts/fck/fckeditor.js") %>" type="text/javascript"></script>  
 <script src="<%=ResolveUrl("~/Scripts/fck/fckeditor.js") %>" type="text/javascript"></script>

Âî view ðåíäåðèì textarea ñ id="HtmlContent", è ïðîïèñûâàåì êëèåíòñêèé êîä èíèöèàëèçàöèè:

  1. <script type="text/javascript">   
  2.        window.onload = function() {   
  3.            var sBasePath = '<%= ResolveUrl("~/Scripts/fck/") %>';   
  4.            var oFCKeditor = new FCKeditor('HtmlContent');   
  5.            oFCKeditor.Config.Enabled = true;   
  6.            oFCKeditor.Config.UserFilesPath = '/Content/UserImages';   
  7.            oFCKeditor.Config.UserFilesAbsolutePath = '/Content/UserImages';   
  8.               
  9.            oFCKeditor.Height = '200';   
  10.            oFCKeditor.BasePath = sBasePath;   
  11.            oFCKeditor.ReplaceTextarea();   
  12.               
  13.        }   
  14.    </script>  
 <script type="text/javascript">
        window.onload = function() {
            var sBasePath = '<%= ResolveUrl("~/Scripts/fck/") %>';
            var oFCKeditor = new FCKeditor('HtmlContent');
            oFCKeditor.Config.Enabled = true;
            oFCKeditor.Config.UserFilesPath = '/Content/UserImages';
            oFCKeditor.Config.UserFilesAbsolutePath = '/Content/UserImages';
            
            oFCKeditor.Height = '200';
            oFCKeditor.BasePath = sBasePath;
            oFCKeditor.ReplaceTextarea();
            
        }
    </script>

Ïàïêà "/Content/UserImages" óêàçàíà äëÿ çàãðóçêè èçîáðàæåíèé. Òàêæå íåîáõîäèìî åùå äîáàâèòü reference íà FredCK.FCKeditorV2.dll. Äëÿ òîãî, ÷òîáû ðàáîòàë çàãðóç÷èê èçîáðàæåíèé çàõîäèì â "/Scripts/fck/filemanager/connectors/aspx/config.ascx".  ìåòîäå CheckAuthentication âîçâðàùàåì true. À â ìåòîäå SetConfig óêàçûâàåì:

  1. // URL path to user files.   
  2. UserFilesPath = "/Content/UserImages/";   
  3.   
  4. // The connector tries to resolve the above UserFilesPath automatically.   
  5. // Use the following setting it you prefer to explicitely specify the   
  6. // absolute path. Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.   
  7. // Attention: The above 'UserFilesPath' URL must point to the same directory.   
  8. UserFilesAbsolutePath = System.IO.Path.Combine(this.Request.PhysicalApplicationPath,"Content\\UserImages");  
// URL path to user files.
UserFilesPath = "/Content/UserImages/";

// The connector tries to resolve the above UserFilesPath automatically.
// Use the following setting it you prefer to explicitely specify the
// absolute path. Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
// Attention: The above 'UserFilesPath' URL must point to the same directory.
UserFilesAbsolutePath = System.IO.Path.Combine(this.Request.PhysicalApplicationPath,"Content\\UserImages");

Âîò è âñ¸. Îòëè÷íûé è áåñïëàòíûé WYSIWYG-ðåäàêòîð, ñ âîçìîæíîñòüþ çàãðóçêè èçîáðàæåíèé ó íàñ â ïðîåêòå :)


Ñòðàíèöà ñàéòà http://185.71.96.61
Îðèãèíàë íàõîäèòñÿ ïî àäðåñó http://185.71.96.61/home.asp?artId=22770