public static IHtmlContent BsIRadioButtonsFor <TModel>(this IHtmlHelper <TModel> html, Expression <Func <TModel, bool> > expression, List <Tuple <string, string, string> > values, ICheckStyle style = ICheckStyle.Flat_Blue, string icon = null, ComponentDirection?dir = null, int lable_col = 2, int editor_col = 4) { string displayName = null; SetVariables(html, expression, ref displayName, out var aaa, out var dirName, out var label, out var validator, out _, lable_col, dir); var editor = html.ICheckRadioButtonsFor(expression, values, style, icon); var result = SetTemplate(label, icon, editor_col, validator, editor.ToHtmlString(), dirName); return(new HtmlString(result)); }
public static MvcHtmlString ICheckCheckBox <TModel>(this HtmlHelper <TModel> html, string name, string label = null, bool value = false, ICheckStyle style = ICheckStyle.Flat_Blue, string icon = null, object htmlAttributes = null) { var id = html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldId(name); var cssClass = style.ToString().ToLower().Replace('_', '-'); html.StyleFileSingle(@"<link href=""" + ComponentUtility.GetWebResourceUrl(iCheck_all_css) + @""" rel=""stylesheet"" />"); html.ScriptFileSingle(@"<script src=""" + ComponentUtility.GetWebResourceUrl(iCheck_js) + @"""></script>"); html.ScriptFileSingle(@"<script src=""" + ComponentUtility.GetWebResourceUrl(iCheck_custom_js) + @"""></script>"); var attributes = ComponentUtility.MergeAttributes(new { @class = $"icheck {cssClass}", id }, htmlAttributes); var radioButton = html.CheckBox(name, value, attributes); var iconTag = string.IsNullOrEmpty(icon) ? "" : $@"<i class=""fa {icon}"" style=""font-size: large;""></i>"; var result = $@" <label for=""{id}""> {radioButton} {iconTag} {label} </label>"; return(new MvcHtmlString(result)); }
public static MvcHtmlString ICheckCheckBoxFor <TModel>(this HtmlHelper <TModel> html, Expression <Func <TModel, bool> > expression, string label = null, ICheckStyle style = ICheckStyle.Flat_Blue, string icon = null, object htmlAttributes = null) { var metadata = ModelMetadata.FromLambdaExpression(expression, html.ViewData); var htmlFieldName = ExpressionHelper.GetExpressionText(expression); //var displayName = metadata.DisplayName ?? metadata.PropertyName ?? htmlFieldName.Split('.').Last(); //var name = html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(htmlFieldName); var id = html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldId(htmlFieldName); var cssClass = " " + style.ToString().ToLower().Replace('_', '-'); var attributes = ComponentUtility.MergeAttributes(htmlAttributes, new { @class = "icheck" + cssClass, id = id + "_" + Guid.NewGuid() }); var result = html.StyleFileSingle(@"<link href=""" + ComponentUtility.GetWebResourceUrl(iCheck_all_css) + @""" rel=""stylesheet"" />") + @" <label for=""" + id + "_" + Guid.NewGuid() + @"""> " + html.CheckBoxFor(expression, attributes) + @" " + (string.IsNullOrEmpty(icon) ? "" : @"<i class=""fa " + icon + @""" style=""font-size: large;""></i>") + " " + label + @" </label>" + html.ScriptFileSingle(@" <script src=""" + ComponentUtility.GetWebResourceUrl(iCheck_js) + @"""></script> ") + html.ScriptFileSingle(@" <script src=""" + ComponentUtility.GetWebResourceUrl(iCheck_custom_js) + @"""></script> "); return(new MvcHtmlString(result)); }
public static MvcHtmlString ICheckRadioButtonsFor <TModel>(this HtmlHelper <TModel> html, Expression <Func <TModel, bool> > expression, List <Tuple <string, string, string> > values, ICheckStyle style = ICheckStyle.Flat_Blue, string icon = null) { var col = Math.Floor(12 / (decimal)values.Count); var result = ""; foreach (var item in values) { result += @" <div class=""col-sm-" + col + @""" style=""padding: 0""> " + html.ICheckRadioButtonFor(expression, item.Item1, item.Item2, style, item.Item3) + @" </div>" + Environment.NewLine; } return(new MvcHtmlString(result)); }
public static IHtmlContent ICheckCheckBox <TModel>(this IHtmlHelper <TModel> html, string name, string label = null, bool value = false, ICheckStyle style = ICheckStyle.Flat_Blue, string icon = null, object htmlAttributes = null) { var id = html.GenerateIdFromName(name); var cssClass = style.ToString().ToLower().Replace('_', '-'); html.StyleOnce(ComponentUtility.GetCssTag(iCheck_all_css, iCheck_all_css_cdn)); html.ScriptOnce(ComponentUtility.GetJsTag(iCheck_js, iCheck_js_cdn)); html.ScriptOnce(ComponentUtility.GetJsTag(iCheck_custom_js, null)); var attributes = ComponentUtility.MergeAttributes(new { @class = $"icheck {cssClass}", id }, htmlAttributes); var radioButton = html.CheckBox(name, value, attributes); var iconTag = string.IsNullOrEmpty(icon) ? "" : $@"<i class=""fa {icon}"" style=""font-size: large;""></i>"; var result = $@" <label for=""{id}""> {radioButton.ToHtmlString()} {iconTag} {label} </label>"; return(new HtmlString(result)); }
public static IHtmlContent ICheckCheckBoxFor <TModel>(this IHtmlHelper <TModel> html, Expression <Func <TModel, bool> > expression, string label = null, ICheckStyle style = ICheckStyle.Flat_Blue, string icon = null, object htmlAttributes = null) { //string htmlFieldName = html.FieldNameFor(expression); //ModelExplorer metadata = html.GetModelExplorer(expression); //var displayName = metadata.Metadata.DisplayName ?? metadata.Metadata.PropertyName ?? htmlFieldName.Split('.').Last(); //var name = html.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(htmlFieldName); var id = html.FieldIdFor(expression); var cssClass = " " + style.ToString().ToLower().Replace('_', '-'); var attributes = ComponentUtility.MergeAttributes(htmlAttributes, new { @class = "icheck" + cssClass, id = id + "_" + Guid.NewGuid() }); var result = html.StyleOnce(ComponentUtility.GetCssTag(iCheck_all_css, iCheck_all_css_cdn)).ToHtmlString() + @" <label for=""" + id + "_" + Guid.NewGuid() + @"""> " + html.CheckBoxFor(expression, attributes).ToHtmlString() + @" " + (string.IsNullOrEmpty(icon) ? "" : @"<i class=""fa " + icon + @""" style=""font-size: large;""></i>") + " " + label + @" </label>" + html.ScriptOnce(ComponentUtility.GetJsTag(iCheck_js, iCheck_js_cdn)).ToHtmlString() + html.ScriptOnce(ComponentUtility.GetJsTag(iCheck_custom_js, null)).ToHtmlString(); return(new HtmlString(result)); }