ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 【重典】Asp.net MVC Fckeditor的扩展(支持PV3及自动绑定)

【重典】Asp.net MVC Fckeditor的扩展(支持PV3及自动绑定)

原创 Linux操作系统 作者:iDotNetSpace 时间:2008-06-02 14:32:50 0 删除 编辑

namespace
 System.Web.Mvc
{
    
using System;
    
using System.Globalization;
    
/// 
    
/// Fckeditor的HTMLHelper
    
/// http://chsword.cnblogs.com/
    
/// 

    static public class FckTextBoxExt
    {
        
/// 
        
/// Fckeditor的HTMLHelper,可以与同名ViewData绑定
        
/// 

        
/// HtmlHelper
        
/// Html的NAME
        
/// 
        public static string FckTextBox(this HtmlHelper u, string name)
        {
            
return u.FckTextBox(name, null);
        }
        
/// 
        
/// Fckeditor的HTMLHelper
        
/// 

        
/// 
        
/// Html name 
        
/// 内容
        
/// 
        public static string FckTextBox(this HtmlHelper u, string name, object value)
        {
            
return u.FckTextBox(name, value.ToString());
        }
        
/// 
        
/// Fckeditor的HTMLHelper
        
/// 

        
/// 
        
/// Html name
        
/// 内容
        
/// 
        public static string FckTextBox(this HtmlHelper u, string name, string value)
        {
            
if (value == null)
            {
                value 
= Convert.ToString(u.ViewDataContainer.ViewData[name], CultureInfo.InvariantCulture);
            }

            
return string.Format(@"{1}

    var oFCKeditor = new FCKeditor('{0}') ;
    //oFCKeditor.BasePath    = sBasePath ;
oFCKeditor.Height=400;
    oFCKeditor.ReplaceTextarea() ;

", name, value);

        }
    }
}


用法
View页写
<%=Html.FckTextBox("content")%>即可
Controller写
ViewData["content"]="
....
";
即可与之绑定

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/12639172/viewspace-329642/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-01-04

  • 博文量
    2376
  • 访问量
    5766042