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的有帮助
  • 相关阅读:
    HDU4911——归并排序——Inversion
    HDU5400——Arithmetic Sequence
    HDU5396——区间DP+排列组合——Expression
    DFS(连通块) ZOJ 2743 Bubble Shooter
    Codeforces Round #345 (Div. 2)
    Codeforces Round #344 (Div. 2)
    8VC Venture Cup 2016
    Manthan, Codefest 16
    DP(记忆化搜索) + AC自动机 LA 4126 Password Suspects
    全排列 UVA 11525 Permutation
  • 原文地址:https://www.cnblogs.com/chsword/p/AspnetExtFckeditor.html
Copyright © 2011-2022 走看看