/// <summary> /// Returns horizontal 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> /// <returns>HtmlString</returns> public static IHtmlContent DisplayFormItemWithTruncate_H <TModel>( this IHtmlHelper <TModel> helper, string value, string labelText = "", int spanOf12 = 6, int textMaxLength = 50, string popOverTitle = "", string seeMoreHtml = " المزيد >>", bool showAllContentInPopover = false, object htmlAttributes = null, bool postBackValue = false, string name = "postValue", TruncateMethod method = TruncateMethod.Popover) { HtmlContentBuilder htmlContentBuilder = new HtmlContentBuilder(); var col = new ItemsColumnTagBuilder(spanOf12, null); var frmGroup = new FormDisplayTagBuilder(); var valueSpan = new SpanTagBuilder(name, value, htmlAttributes); valueSpan.InnerHtml.AppendHtml(helper.DisplayWithTruncate(name, value, textMaxLength, popOverTitle, seeMoreHtml, showAllContentInPopover, method)); htmlContentBuilder.AppendHtml(col.RenderStartTag()) .AppendHtml(frmGroup.RenderStartTag()) .AppendHtml(helper.Label(labelText)); htmlContentBuilder.AppendHtml(valueSpan); if (postBackValue) { htmlContentBuilder.AppendHtml(helper.Hidden(name, value)); } htmlContentBuilder.AppendHtml(frmGroup.RenderEndTag()) .AppendHtml(col.RenderEndTag()); return(htmlContentBuilder); }
/// <summary> /// Returns display value for model property with the display name as caption in bootstrap horizontal 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> /// <returns>HtmlString</returns> public static IHtmlContent DisplayFormItemFor_H <TModel, TProperty>( this IHtmlHelper <TModel> helper, Expression <Func <TModel, TProperty> > expression, int spanOf12 = 6, object htmlAttributes = null, bool postBackValue = false) { 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 valueSpan = new SpanTagBuilder(name, htmlAttributes); valueSpan.InnerHtml.AppendHtml(helper.DisplayFor(expression)); htmlContentBuilder.AppendHtml(col.RenderStartTag()) .AppendHtml(frmGroup.RenderStartTag()) .AppendHtml(helper.LabelFor(expression)) .AppendHtml(valueSpan); if (postBackValue) { htmlContentBuilder.AppendHtml(helper.HiddenFor(expression)); } htmlContentBuilder.AppendHtml(frmGroup.RenderEndTag()) .AppendHtml(col.RenderEndTag()); return(htmlContentBuilder); }
/// <summary> /// Returns horizontal 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> /// <returns>HtmlString</returns> public static IHtmlContent DisplayFormItemWithTruncateFor_H <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, 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 valueSpan = new SpanTagBuilder(name, htmlAttributes); valueSpan.InnerHtml.AppendHtml(helper.DisplayWithTruncateFor(expression, textMaxLength, popOverTitle, seeMoreHtml, showAllContentInPopover, method)); htmlContentBuilder.AppendHtml(col.RenderStartTag()) .AppendHtml(frmGroup.RenderStartTag()) .AppendHtml(helper.LabelFor(expression)); htmlContentBuilder.AppendHtml(valueSpan); if (postBackValue) { htmlContentBuilder.AppendHtml(helper.HiddenFor(expression)); } htmlContentBuilder.AppendHtml(frmGroup.RenderEndTag()) .AppendHtml(col.RenderEndTag()); return(htmlContentBuilder); }
/// <summary> /// Returns display value with caption as bootstrap horizontal 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> /// <returns>HtmlString</returns> public static IHtmlContent DisplayFormItem_H <TModel>( this IHtmlHelper <TModel> helper, string value, string labelText = "", int spanOf12 = 6, object htmlAttributes = null, bool postBackValue = false, string name = "postValue") { HtmlContentBuilder htmlContentBuilder = new HtmlContentBuilder(); var col = new ItemsColumnTagBuilder(spanOf12, null); var frmGroup = new FormDisplayTagBuilder(); var valueSpan = new SpanTagBuilder(name, value, htmlAttributes); htmlContentBuilder.AppendHtml(col.RenderStartTag()) .AppendHtml(frmGroup.RenderStartTag()) .AppendHtml(helper.Label(labelText)) .AppendHtml(valueSpan); if (postBackValue) { htmlContentBuilder.AppendHtml(helper.Hidden(name, value)); } htmlContentBuilder.AppendHtml(frmGroup.RenderEndTag()) .AppendHtml(col.RenderEndTag()); return(htmlContentBuilder); }