zoukankan      html  css  js  c++  java
  • Asp.net MVC Fckeditor的扩展(支持PV3及自动绑定)


    namespace
     System.Web.Mvc
    {
        
    using System;
        
    using System.Globalization;
        
    /// <summary>
        
    /// Fckeditor的HTMLHelper
        
    /// http://chsword.cnblogs.com/
        
    /// </summary>
        static public class FckTextBoxExt
        {
            
    /// <summary>
            
    /// Fckeditor的HTMLHelper,可以与同名ViewData绑定
            
    /// </summary>
            
    /// <param name="u">HtmlHelper</param>
            
    /// <param name="name">Html的NAME</param>
            
    /// <returns></returns>
            public static string FckTextBox(this HtmlHelper u, string name)
            {
                
    return u.FckTextBox(name, null);
            }
            
    /// <summary>
            
    /// Fckeditor的HTMLHelper
            
    /// </summary>
            
    /// <param name="u"></param>
            
    /// <param name="name">Html name </param>
            
    /// <param name="value">内容</param>
            
    /// <returns></returns>
            public static string FckTextBox(this HtmlHelper u, string name, object value)
            {
                
    return u.FckTextBox(name, value.ToString());
            }
            
    /// <summary>
            
    /// Fckeditor的HTMLHelper
            
    /// </summary>
            
    /// <param name="u"></param>
            
    /// <param name="name">Html name</param>
            
    /// <param name="value">内容</param>
            
    /// <returns></returns>
            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(@"<textarea name=""{0}"" id=""{0}"" rows=""50"" cols=""80"" style=""100%; height: 600px"">{1}</textarea>
    <script type=""text/javascript"">
        var oFCKeditor = new FCKeditor('{0}') ;
        //oFCKeditor.BasePath    = sBasePath ;
    oFCKeditor.Height=400;
        oFCKeditor.ReplaceTextarea() ;
    </script>
    ", name, value);

            }
        }
    }


    用法
    View页写
    <%=Html.FckTextBox("content")%>即可
    Controller写
    ViewData["content"]="<div>....</div>";
    即可与之绑定
    希望对大家自己扩展MVC的有帮助
  • 相关阅读:
    typora 页内跳转
    shell脚本搭建redis集群
    Html
    python json模块
    jenkins 问题合集
    day05 每日一行
    day04 每次一行
    day03 每日一行
    day02
    day02 每日一行
  • 原文地址:https://www.cnblogs.com/chsword/p/AspnetExtFckeditor.html
Copyright © 2011-2022 走看看