![]() |
Çàïóñêàåì FCKeditor ïîä ASP.NET MVCÈñòî÷íèê: progblog
Äëÿ ðàáîòû ïîíàäîáÿòñÿ:
Äàëåå ïðîñòî äîáàâëÿåì â ïðîåêò ïàïêó "fck" ñî ñêðèïòàìè. È ïîäêëþ÷àåì fckeditor.js â ìàñòåð ñòðàíèöå.
<script src="<%=ResolveUrl("~/Scripts/fck/fckeditor.js") %>" type="text/javascript"></script>
Âî view ðåíäåðèì textarea ñ id="HtmlContent", è ïðîïèñûâàåì êëèåíòñêèé êîä èíèöèàëèçàöèè:
<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 óêàçûâàåì:
// 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-ðåäàêòîð, ñ âîçìîæíîñòüþ çàãðóçêè èçîáðàæåíèé ó íàñ â ïðîåêòå :) |