Example #1
0
        /// <summary>
        /// 生成编辑器的Html
        /// </summary>
        /// <param name="name">RichTextEditor的名称</param>
        /// <param name="date">RichTextEditor的值</param>
        /// <returns>html文本</returns>
        private static MvcHtmlString GenerateHtml(this HtmlHelper html, string name, RichTextEditor model)
        {
            var map = new ViewDataDictionary();

            map["RichTextEditorName"] = name;
            if (model.Plugins == RichTextEditorPlugins.UEDITOR)
            {
                return(html.Partial("_UEditor", model, map));
            }

            return(html.Partial("_RichTextEditor", model, map));
        }
Example #2
0
        /// <summary>
        /// 通过lambda表达式生成控件
        /// </summary>
        /// <param name="helper">HtmlHelper对象</param>
        /// <param name="expression">lambda表达式,指定要显示的属性及其所属对象</param>
        /// <param name="model"></param>
        /// <returns>Html文本</returns>
        public static MvcHtmlString RichTextEditorFor <TModel, TProperty>(this HtmlHelper <TModel> helper,
                                                                          Expression <Func <TModel, TProperty> > expression, RichTextEditor model)
        {
            if (model == null)
            {
                model = new RichTextEditor();
            }

            string name = ExpressionHelper.GetExpressionText(expression);
            var    val  = ModelMetadata.FromLambdaExpression <TModel, TProperty>(expression, helper.ViewData).Model;

            if (val != null)
            {
                model.Cnt = val.ToString();
            }

            return(GenerateHtml(helper, name, model));
        }
Example #3
0
 /// <summary>
 /// 使用特定的名称和初始值生成控件
 /// <para>一个页面只能使用一种类型编辑器</para>
 /// </summary>
 /// <param name="helper">HtmlHelper对象</param>
 /// <param name="name">控件名称</param>
 /// <param name="model">编辑器配置</param>
 /// <returns>Html文本</returns>
 public static MvcHtmlString RichTextEditor(this HtmlHelper helper, string name, RichTextEditor model)
 {
     return(GenerateHtml(helper, name, model ?? new RichTextEditor()));
 }