public override MvcHtmlString Render() { var stringBuilder = new StringBuilder(); stringBuilder.Append(Label.Render()); var controlContainer = IncodingHtmlHelper.CreateTag(HtmlTag.Div, Input.Render(), new RouteValueDictionary(new { @class = "controls" })); stringBuilder.Append(controlContainer); stringBuilder.Append(Validation.Render()); stringBuilder.Append(HelpBlock.Render()); var controlGroup = IncodingHtmlHelper.CreateTag(HtmlTag.Div, new MvcHtmlString(stringBuilder.ToString()), AnonymousHelper.ToDictionary(this.attributes)); return(new MvcHtmlString(controlGroup.ToString())); }
public override MvcHtmlString ToHtmlString() { Func <IncControlBase, bool> isForDefClass = @base => [email protected](HtmlAttribute.Class).With(r => r.Contains("col-")); bool isV3orMore = IncodingHtmlHelper.BootstrapVersion == BootstrapOfVersion.v3; bool isStatic = Input.GetType().Name.Contains("IncStaticControl"); AddClass(isV3orMore ? B.Form_group.ToLocalization() : "control-group"); Label.AddClass(B.Control_label); if (isV3orMore && isForDefClass(Label)) { Label.AddClass(IncodingHtmlHelper.Def_Label_Class.ToLocalization()); } if (!isV3orMore) { Control.AddClass("controls"); } if (string.IsNullOrWhiteSpace(Control.GetAttr(HtmlAttribute.Class))) { Control.AddClass(isV3orMore ? IncodingHtmlHelper.Def_Control_Class.ToLocalization() : isStatic ? string.Empty : "control-group"); } var stringBuilder = new StringBuilder(); stringBuilder.Append(Label.ToHtmlString()); if (isV3orMore && !typeof(TInput).Name.Contains("IncCheckBoxControl")) { Input.AddClass(isStatic ? B.Form_static_control.ToLocalization() : B.Form_control.ToLocalization()); } Control.Content = Input.ToHtmlString(); stringBuilder.Append(Control.ToHtmlString()); stringBuilder.Append(Validation.ToHtmlString()); stringBuilder.Append(HelpBlock.ToHtmlString()); var controlGroup = IncodingHtmlHelper.CreateTag(HtmlTag.Div, new MvcHtmlString(stringBuilder.ToString()), GetAttributes()); return(new MvcHtmlString(controlGroup.ToString())); }