(495) 925-0049, ITShop интернет-магазин 229-0436, Учебный Центр 925-0049
  Главная страница Карта сайта Контакты
Поиск
Вход
Регистрация
Рассылки сайта
 
 
 
 
 

Запускаем 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-редактор, с возможностью загрузки изображений у нас в проекте :)

Ссылки по теме


 Распечатать »
 Правила публикации »
  Написать редактору 
 Рекомендовать » Дата публикации: 01.12.2009 
 

Магазин программного обеспечения   WWW.ITSHOP.RU
Microsoft Office для дома и учебы 2019 (лицензия ESD)
Microsoft Office 365 Персональный 32-bit/x64. 1 ПК/MAC + 1 Планшет + 1 Телефон. Все языки. Подписка на 1 год.
Microsoft 365 Business Basic (corporate)
Microsoft Windows Professional 10, Электронный ключ
Microsoft 365 Apps for business (corporate)
 
Другие предложения...
 
Курсы обучения   WWW.ITSHOP.RU
 
Другие предложения...
 
Магазин сертификационных экзаменов   WWW.ITSHOP.RU
 
Другие предложения...
 
3D Принтеры | 3D Печать   WWW.ITSHOP.RU
 
Другие предложения...
 
Новости по теме
 
Рассылки Subscribe.ru
Информационные технологии: CASE, RAD, ERP, OLAP
Безопасность компьютерных сетей и защита информации
Новости ITShop.ru - ПО, книги, документация, курсы обучения
Программирование на Microsoft Access
CASE-технологии
Программирование в AutoCAD
Все о PHP и даже больше
 
Статьи по теме
 
Новинки каталога Download
 
Исходники
 
Документация
 
 



    
rambler's top100 Rambler's Top100