Ejemplo n.º 1
0
        /// <summary>
        /// Returns display item of a value with caption truncated by the given length and use bootstrap pop-over to display the complete value
        /// </summary>
        /// <param name="name">Unique name for the display tag</param>
        /// <param name="value">Value to display</param>
        /// <param name="labelText">Item caption text</param>
        /// <param name="spanOf12">Number represents bootstrap column span for the item width</param>
        /// <param name="textMaxLength">Maximum length of the displayed text</param>
        /// <param name="popOverTitle">The pop-over title text</param>
        /// <param name="seeMoreHtml">html text for see more if the text is truncated</param>
        /// <param name="showAllContentInPopover">True if you want to show the complete value in the pop-over. False to display the rest of the value only</param>
        /// <param name="htmlAttributes">custom htmlAttributes applied to the value tag</param>
        /// <param name="postBackValue">If true, value will be posted back in hidden input field</param>
        ///  <param name="hint">Optional text to add after the caption label as a hint</param>
        /// <returns>HtmlString</returns>
        public static IHtmlContent DisplayFormItemWithTruncate <TModel>(
            this IHtmlHelper <TModel> helper, string name, string value, string labelText = "", int spanOf12 = 6,
            int textMaxLength     = 50, string popOverTitle  = "", string seeMoreHtml = " المزيد >>", bool showAllContentInPopover = false,
            object htmlAttributes = null, bool postBackValue = false, string hint     = "", TruncateMethod method = TruncateMethod.Popover)
        {
            HtmlContentBuilder htmlContentBuilder = new HtmlContentBuilder();

            var col          = new ItemsColumnTagBuilder(spanOf12, null);
            var frmGroup     = new FormGroupTagBuilder();
            var valueDisplay = new ParagraphTagBuilder(name, htmlAttributes);

            valueDisplay.InnerHtml.AppendHtml(helper.DisplayWithTruncate(name, value, textMaxLength, popOverTitle, seeMoreHtml, showAllContentInPopover, method));

            htmlContentBuilder.AppendHtml(col.RenderStartTag())
            .AppendHtml(frmGroup.RenderStartTag())
            .AppendHtml(helper.Label(labelText));

            if (!string.IsNullOrEmpty(hint))
            {
                htmlContentBuilder.AppendHtml(new FormItemHintTagBuilder(hint));
            }

            htmlContentBuilder.AppendHtml(valueDisplay);

            if (postBackValue)
            {
                htmlContentBuilder.AppendHtml(helper.Hidden(name, value));
            }

            htmlContentBuilder.AppendHtml(frmGroup.RenderEndTag())
            .AppendHtml(col.RenderEndTag());

            return(htmlContentBuilder);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns display value with caption as bootstrap form item
        /// </summary>
        /// <param name="value">Item value to display</param>
        /// <param name="labelText">Item caption text</param>
        /// <param name="spanOf12">Number represents bootstrap column span for the item width</param>
        /// <param name="htmlAttributes">custom htmlAttributes applied to the value tag</param>
        /// <param name="postBackValue">If true, value will be posted back in hidden input field</param>
        /// <param name="name">Unique name for the hidden field</param>
        ///  <param name="hint">Optional text to add after the caption label as a hint</param>
        /// <returns>HtmlString</returns>
        public static IHtmlContent DisplayFormItem <TModel>(
            this IHtmlHelper <TModel> helper, string value, string labelText = "", int spanOf12 = 6, object htmlAttributes = null, bool postBackValue = false, string name = "postValue", string hint = "")
        {
            HtmlContentBuilder htmlContentBuilder = new HtmlContentBuilder();

            var col            = new ItemsColumnTagBuilder(spanOf12, null);
            var frmGroup       = new FormGroupTagBuilder();
            var valueParagraph = new ParagraphTagBuilder(name, value, htmlAttributes);

            htmlContentBuilder.AppendHtml(col.RenderStartTag())
            .AppendHtml(frmGroup.RenderStartTag())
            .AppendHtml(helper.Label(labelText));

            if (!string.IsNullOrEmpty(hint))
            {
                htmlContentBuilder.AppendHtml(new FormItemHintTagBuilder(hint));
            }

            htmlContentBuilder.AppendHtml(valueParagraph);

            if (postBackValue)
            {
                htmlContentBuilder.AppendHtml(helper.Hidden(name, value));
            }

            htmlContentBuilder.AppendHtml(frmGroup.RenderEndTag())
            .AppendHtml(col.RenderEndTag());

            return(htmlContentBuilder);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Returns display item of a model value with caption truncated by the given length and use bootstrap pop-over to display the complete value
        /// </summary>
        /// <param name="expression">Lambda expression for the property</param>
        /// <param name="spanOf12">Number represents bootstrap column span for the item width</param>
        /// <param name="textMaxLength">Maximum length of the displayed text</param>
        /// <param name="popOverTitle">The pop-over title text</param>
        /// <param name="seeMoreHtml">html text for see more if the text is truncated</param>
        /// <param name="showAllContentInPopover">True if you want to show the complete value in the pop-over. False to display the rest of the value only</param>
        /// <param name="htmlAttributes">custom htmlAttributes applied to the value tag</param>
        /// <param name="postBackValue">If true, value will be posted back in hidden input field</param>
        ///  <param name="hint">Optional text to add after the caption label as a hint</param>
        /// <returns>HtmlString</returns>
        public static IHtmlContent DisplayFormItemWithTruncateFor <TModel, TProperty>(
            this IHtmlHelper <TModel> helper,
            Expression <Func <TModel, TProperty> > expression, int spanOf12 = 6,
            int textMaxLength            = 50, string popOverTitle = "", string seeMoreHtml = " المزيد >>",
            bool showAllContentInPopover = false, object htmlAttributes = null, bool postBackValue = false, string hint = "", TruncateMethod method = TruncateMethod.Popover)
        {
            var expresionProvider = helper.ViewContext.HttpContext.RequestServices
                                    .GetService(typeof(ModelExpressionProvider)) as ModelExpressionProvider;
            string name = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(expresionProvider.GetExpressionText(expression));

            HtmlContentBuilder htmlContentBuilder = new HtmlContentBuilder();

            var col            = new ItemsColumnTagBuilder(spanOf12, null);
            var frmGroup       = new FormDisplayTagBuilder();
            var valueParagraph = new ParagraphTagBuilder(name, htmlAttributes);

            valueParagraph.InnerHtml.AppendHtml(helper.DisplayWithTruncateFor(expression, textMaxLength, popOverTitle, seeMoreHtml, showAllContentInPopover, method));

            htmlContentBuilder.AppendHtml(col.RenderStartTag())
            .AppendHtml(frmGroup.RenderStartTag())
            .AppendHtml(helper.LabelFor(expression));

            if (!string.IsNullOrEmpty(hint))
            {
                htmlContentBuilder.AppendHtml(new FormItemHintTagBuilder(hint));
            }

            htmlContentBuilder.AppendHtml(valueParagraph);

            if (postBackValue)
            {
                htmlContentBuilder.AppendHtml(helper.HiddenFor(expression));
            }

            htmlContentBuilder.AppendHtml(frmGroup.RenderEndTag())
            .AppendHtml(col.RenderEndTag());

            return(htmlContentBuilder);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns display value for model property with the display name as caption in bootstrap form item
        /// </summary>
        /// <param name="expression">Lambda expression for the property</param>
        /// <param name="spanOf12">Number represents bootstrap column span for the item width</param>
        /// <param name="htmlAttributes">custom htmlAttributes applied to the value tag</param>
        /// <param name="postBackValue">If true, value will be posted back in hidden input field</param>
        /// <param name="hint">Optional text to add after the caption label as a hint</param>
        /// <returns>HtmlString</returns>
        public static IHtmlContent DisplayFormItemFor <TModel, TProperty>(
            this IHtmlHelper <TModel> helper,
            Expression <Func <TModel, TProperty> > expression, int spanOf12 = 6, object htmlAttributes = null, bool postBackValue = false, string hint = "")
        {
            var expresionProvider = helper.ViewContext.HttpContext.RequestServices
                                    .GetService(typeof(ModelExpressionProvider)) as ModelExpressionProvider;
            HtmlContentBuilder htmlContentBuilder = new HtmlContentBuilder();
            string             name = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(expresionProvider.GetExpressionText(expression));

            var col            = new ItemsColumnTagBuilder(spanOf12, null);
            var frmGroup       = new FormGroupTagBuilder();
            var valueParagraph = new ParagraphTagBuilder(name, htmlAttributes);

            valueParagraph.InnerHtml.AppendHtml(helper.DisplayFor(expression));

            htmlContentBuilder.AppendHtml(col.RenderStartTag())
            .AppendHtml(frmGroup.RenderStartTag())
            .AppendHtml(helper.LabelFor(expression));

            if (!string.IsNullOrEmpty(hint))
            {
                htmlContentBuilder.AppendHtml(new FormItemHintTagBuilder(hint));
            }

            htmlContentBuilder.AppendHtml(valueParagraph);

            if (postBackValue)
            {
                htmlContentBuilder.AppendHtml(helper.HiddenFor(expression));
            }

            htmlContentBuilder.AppendHtml(frmGroup.RenderEndTag())
            .AppendHtml(col.RenderEndTag());

            return(htmlContentBuilder);
        }