点击这里给我发消息 点击这里给我发消息

Asp.net MVC Fckeditor的扩展

添加时间:2010-7-16
    相关阅读: HTML VC

1 namespace System.Web.Mvc

  2 {

  3     using System;

  4     using System.Globalization;

  5     /// <summary>

  6     /// Fckeditor的HTMLHelper

  7     /// http://chsword.cnblogs.com/

  8     /// </summary>

  9      static public class FckTextBoxExt

  10     {

  11         /// <summary>

  12         /// Fckeditor的HTMLHelper,可以与同名ViewData绑定

  13         /// </summary>

  14         /// <param name="u">HtmlHelper</param>

  15         /// <param name="name">Html的NAME</param>

  16         /// <returns></returns>

  17         public static string FckTextBox(this HtmlHelper u, string name)

  18         {

  19             return u.FckTextBox(name, null);

  20         }

  21         /// <summary>

  22         /// Fckeditor的HTMLHelper

  23         /// </summary>

  24         /// <param name="u"></param>

  25         /// <param name="name">Html name </param>

  26         /// <param name="value">内容</param>

  27         /// <returns></returns>

  28         public static string FckTextBox(this HtmlHelper u, string name, object value)

  29         {

  30             return u.FckTextBox(name, value.ToString());

  31         }

  32         /// <summary>

  33         /// Fckeditor的HTMLHelper

  34         /// </summary>

  35         /// <param name="u"></param>

  36         /// <param name="name">Html name</param>

  37         /// <param name="value">内容</param>

  38         /// <returns></returns>

  39         public static string FckTextBox(this HtmlHelper u, string name, string value)

  40         {

  41             if (value == null)

  42             {

  43                 value = Convert.ToString(u.ViewDataContainer.ViewData[name], CultureInfo.InvariantCulture);

  44             }

  45

  46             return string.Format(@"<textarea name=""{0}"" id=""{0}"" rows=""50"" cols=""80"" style=""width:100%; height: 600px"">{1}</textarea>

  47 <script type=""text/javascript"">

  48     var oFCKeditor = new FCKeditor('{0}') ;

  49     //oFCKeditor.BasePath    = sBasePath ;

  50 oFCKeditor.Height=400;

  51     oFCKeditor.ReplaceTextarea() ;

  52 </script>

  53 ", name, value);

  54

  55         }

  56     }

  57 }

  用法

  View页写

  <%=Html.FckTextBox("content")%>即可

  Controller写

  ViewData["content"]="<div>....</div>";

  即可与之绑定

本文作者:未知
咨询热线:020-85648757 85648755 85648616 0755-27912581 客服:020-85648756 0755-27912581 业务传真:020-32579052
广州市网景网络科技有限公司 Copyright◎2003-2008 Veelink.com. All Rights Reserved.
广州商务地址:广东省广州市黄埔大道中203号(海景园区)海景花园C栋501室
= 深圳商务地址:深圳市宝源路华丰宝源大厦606
研发中心:广东广州市天河软件园海景园区 粤ICP备05103322号 工商注册