public FormContainer(HtmlTextWriter htmlTextWriter, string url, BootstrapFormType formType = BootstrapFormType.Horizontal, FormMethod method = FormMethod.Post, object htmlAttributes = null) { this.textWriter = htmlTextWriter; this.formType = formType; textWriter.AddAttribute("method", method.ToString()); textWriter.AddAttribute("action", url); var htmlAttributesCollection = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes); switch (this.formType) { case BootstrapFormType.Horizontal: htmlAttributesCollection.Merge("class", "form-horizontal"); break; case BootstrapFormType.Vertical: htmlAttributesCollection.Merge("class", "form-vertical"); break; case BootstrapFormType.Inline: htmlAttributesCollection.Merge("class", "form-inline"); break; } foreach (var htmlAttribute in htmlAttributesCollection) { textWriter.AddAttribute(htmlAttribute.Key, htmlAttribute.Value.ToString()); } textWriter.RenderBeginTag(HtmlTextWriterTag.Form); }
public FormContainer(HtmlTextWriter htmlTextWriter, string url , BootstrapFormType formType = BootstrapFormType.Horizontal, FormMethod method = FormMethod.Post, object htmlAttributes = null) { this.textWriter = htmlTextWriter; this.formType = formType; // textWriter.AddAttribute("method", method.ToString()); //textWriter.AddAttribute("action", url ) ; var htmlAttributesCollection = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes); switch (this.formType) { case BootstrapFormType.Horizontal: htmlAttributesCollection.Merge("class", "form-horizontal"); break; case BootstrapFormType.Vertical: htmlAttributesCollection.Merge("class", "form-vertical"); break; case BootstrapFormType.Inline: htmlAttributesCollection.Merge("class", "form-inline"); break; } foreach (var htmlAttribute in htmlAttributesCollection) { textWriter.AddAttribute(htmlAttribute.Key, htmlAttribute.Value.ToString()); } textWriter.RenderBeginTag(HtmlTextWriterTag.Form); }
public BootstrapFormBuilder <TModel> BeginForm(BootstrapFormType formType) { string rawUrl = this.helper.ViewContext.HttpContext.Request.RawUrl; return(new BootstrapFormBuilder <TModel>( this.helper, new BootstrapForm(formType, rawUrl, FormMethod.Post, new RouteValueDictionary()))); }
public BootstrapFormBuilder <TModel> BeginForm(BootstrapFormType formType, IDictionary <string, object> htmlAttributes) { string rawUrl = this.helper.ViewContext.HttpContext.Request.RawUrl; return(new BootstrapFormBuilder <TModel>( this.helper, new BootstrapForm(formType, rawUrl, FormMethod.Post, htmlAttributes))); }
public BootstrapFormBuilder <TModel> BeginForm(BootstrapFormType formType, object htmlAttributes) { string rawUrl = _helper.ViewContext.HttpContext.Request.RawUrl; return(new BootstrapFormBuilder <TModel>( _helper, new BootstrapForm(formType, rawUrl, FormMethod.Post, new RouteValueDictionary(htmlAttributes)))); }
public FormContainer BeginForm(BootstrapFormType formType) { var rawUrl = this.helper.ViewContext.HttpContext.Request.RawUrl; var textWriter = new HtmlTextWriter(helper.ViewContext.Writer); var fc = new FormContainer(textWriter, rawUrl); return(fc); }
public MvcHtmlString BuildForm(BootstrapFormType formType, List<FormElement> formElements) { var formBuilderParameters = new BuilderParameters(formType); var formMarkUp = this.formBuilder.BuildForm(formElements, formBuilderParameters); return new MvcHtmlString(formMarkUp); }
public FormContainer BeginForm(BootstrapFormType formType, object htmlAttributes) { var rawUrl = this.helper.ViewContext.HttpContext.Request.RawUrl; var textWriter = new HtmlTextWriter(helper.ViewContext.Writer); var fc = new FormContainer(textWriter, rawUrl, method: FormMethod.Post, htmlAttributes: htmlAttributes); return(fc); }
public MvcHtmlString BuildForm(BootstrapFormType formType, List <FormElement> formElements) { var formBuilderParameters = new BuilderParameters(formType); var formMarkUp = this.formBuilder.BuildForm(formElements, formBuilderParameters); return(new MvcHtmlString(formMarkUp)); }
public static MvcHtmlString DynamicForm <TModel> (this HtmlHelper <TModel> htmlHelper, BootstrapFormType formType = BootstrapFormType.Horizontal) { TModel model = htmlHelper.ViewData.Model; var elements = new FormElementsProvider <TModel>().ExtractElementsFromModel(model, htmlHelper); return(new BootStrapUIBuilder(Mode.Edit).BuildForm(formType, elements)); }
public MvcHtmlString BuildElement(BootstrapFormType formType, FormElement formElement) { var sb = new StringBuilder(); var formBuilderParameters = new BuilderParameters(formType); sb.Append(this.formBuilder.RenderElement(formElement, formBuilderParameters)); return(new MvcHtmlString(sb.ToString())); }
public MvcHtmlString BuildForm(BootstrapFormType formType, List<FormElement> formElements) { var sb = new StringBuilder(); var formBuilderParameters = new BuilderParameters(formType); sb.Append(this.formBuilder.BuildForm(formElements, formBuilderParameters)); return new MvcHtmlString(sb.ToString()); }
public MvcHtmlString BuildElement(BootstrapFormType formType, FormElement formElement) { var sb = new StringBuilder(); var formBuilderParameters = new BuilderParameters(formType); sb.Append(this.formBuilder.RenderElement(formElement, formBuilderParameters)); return new MvcHtmlString(sb.ToString()); }
public MvcHtmlString BuildForm(BootstrapFormType formType, List <FormElement> formElements) { var sb = new StringBuilder(); var formBuilderParameters = new BuilderParameters(formType); sb.Append(this.formBuilder.BuildForm(formElements, formBuilderParameters)); return(new MvcHtmlString(sb.ToString())); }
public static void Begin(HtmlTextWriter htmlTextWriter, BootstrapFormType formType = BootstrapFormType.Horizontal) { var textWriter = htmlTextWriter; if (formType == BootstrapFormType.Horizontal) { // Controls Div textWriter.AddAttribute(HtmlTextWriterAttribute.Class, "col-lg-9"); } textWriter.RenderBeginTag(HtmlTextWriterTag.Div); }
public BootstrapForm(BootstrapFormType formType, string formAction, FormMethod method, IDictionary<string, object> htmlAttributes) : base("form", htmlAttributes) { this.FormType = formType; EnsureHtmlAttribute("action", formAction); EnsureHtmlAttribute("method", HtmlHelper.GetFormMethodString(method), true); switch (this.FormType) { case BootstrapFormType.Horizontal: EnsureClass("form-horizontal"); break; case BootstrapFormType.Vertical: EnsureClass("form-vertical"); break; case BootstrapFormType.Inline: EnsureClass("form-inline"); break; case BootstrapFormType.Search: EnsureClass("form-search"); break; } }
public virtual MvcHtmlString Build(TModel model, BootstrapFormType formType, bool renderButtons = true) { var sb = new StringBuilder(2000); var formElements = ExtractElementsToRender(model); var groupsofElements = formElements.OrderBy(x => x.ControlSpecs.GroupName).GroupBy(x => x.ControlSpecs.GroupName); bool useLegend = (formElements.Select(x => x.ControlSpecs.GroupName).Distinct().Count() > 1); var stringWriter = new StringWriter(sb); using (var textWriter = new NavHtmlTextWritter(stringWriter)) { RenderHiddenFields(model, formElements, textWriter); foreach (var groupedElements in groupsofElements) { var groupName = (!String.IsNullOrEmpty(groupedElements.Key)) ? groupedElements.Key : "General"; using (new ElementGroup(textWriter, groupName, useLegend)) { var elementsToRender = groupedElements.Where(x => x.ControlSpecs.Control != ControlType.Hidden) .OrderBy(x => x.ControlSpecs.Order); // loop over the attributes (ordered).. foreach (var formElement in elementsToRender) { using (new ControlGroup(textWriter)) { ControlGroup.RenderLabel(formType, formElement, textWriter); using (new ControlContainer(textWriter)) { // Control RenderElement(textWriter, model, formElement); } } } } } if (renderButtons) { RenderButtons(textWriter); } return(new MvcHtmlString(sb.ToString())); } }
public BootstrapForm(BootstrapFormType formType, string formAction, FormMethod method, IDictionary <string, object> htmlAttributes) : base("form", htmlAttributes) { this.FormType = formType; EnsureHtmlAttribute("action", formAction); EnsureHtmlAttribute("method", HtmlHelper.GetFormMethodString(method), true); switch (this.FormType) { case BootstrapFormType.Horizontal: EnsureClass("form-horizontal"); break; case BootstrapFormType.Vertical: EnsureClass("form-vertical"); break; case BootstrapFormType.Inline: EnsureClass("form-inline"); break; case BootstrapFormType.Search: EnsureClass("form-search"); break; } }
public BootstrapFormBuilder <TModel> BeginRouteForm(string routeName, RouteValueDictionary routeValues, FormMethod method, BootstrapFormType formType = BootstrapFormType.Horizontal) { return(BeginRouteForm(routeName, routeValues, method, new RouteValueDictionary(), formType)); }
public BootstrapFormBuilder <TModel> BeginRouteForm(string routeName, FormMethod method, IDictionary <string, object> htmlAttributes, BootstrapFormType formType = BootstrapFormType.Horizontal) { return(BeginRouteForm(routeName, new RouteValueDictionary(), method, htmlAttributes, formType)); }
public BootstrapFormBuilder <TModel> BeginRouteForm(string routeName, object routeValues, BootstrapFormType formType = BootstrapFormType.Horizontal) { return(BeginRouteForm(routeName, new RouteValueDictionary(routeValues), FormMethod.Post, new RouteValueDictionary(), formType)); }
public BootstrapFormBuilder <TModel> BeginRouteForm(RouteValueDictionary routeValues, BootstrapFormType formType = BootstrapFormType.Horizontal) { return(BeginRouteForm(null, routeValues, FormMethod.Post, new RouteValueDictionary(), formType)); }
public BootstrapFormBuilder <TModel> BeginForm(string actionName, string controllerName, RouteValueDictionary routeValues, FormMethod method, BootstrapFormType formType = BootstrapFormType.Horizontal) { return(BeginForm(actionName, controllerName, routeValues, method, new RouteValueDictionary(), formType)); }
public BootstrapFormBuilder <TModel> BeginForm(string actionName, string controllerName, RouteValueDictionary routeValues, FormMethod method, IDictionary <string, object> htmlAttributes, BootstrapFormType formType = BootstrapFormType.Horizontal) { string formAction = UrlHelper.GenerateUrl(null, actionName, controllerName, routeValues, _helper.RouteCollection, _helper.ViewContext.RequestContext, true); return(new BootstrapFormBuilder <TModel>( _helper, new BootstrapForm(formType, formAction, method, htmlAttributes))); }
public BuilderParameters(BootstrapFormType formType) { this.formType = formType; }
public BootstrapFormBuilder <TModel> BeginRouteForm(string routeName, object routeValues, FormMethod method, object htmlAttributes, BootstrapFormType formType = BootstrapFormType.Horizontal) { return(BeginRouteForm(routeName, new RouteValueDictionary(routeValues), method, HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes), formType)); }
public FormContainer BeginForm(string actionName, string controllerName, RouteValueDictionary routeValues, FormMethod method, object htmlAttributes, BootstrapFormType formType = BootstrapFormType.Horizontal) { var formAction = UrlHelper.GenerateUrl(null, actionName, controllerName, routeValues, this.helper.RouteCollection, this.helper.ViewContext.RequestContext, true); var textWriter = new HtmlTextWriter(helper.ViewContext.Writer); var fc = new FormContainer(textWriter, formAction, method: method, htmlAttributes: htmlAttributes, formType: formType); return(fc); }
public BootstrapFormBuilder <TModel> BeginRouteForm(string routeName, RouteValueDictionary routeValues, FormMethod method, IDictionary <string, object> htmlAttributes, BootstrapFormType formType = BootstrapFormType.Horizontal) { string formAction = UrlHelper.GenerateUrl(routeName, null, null, routeValues, this.helper.RouteCollection, this.helper.ViewContext.RequestContext, false); return(new BootstrapFormBuilder <TModel>( this.helper, new BootstrapForm(formType, formAction, method, htmlAttributes))); }
public static MvcHtmlString DynamicViewElement <TModel, TProperty>(this HtmlHelper <TModel> htmlHelper, Expression <Func <TModel, TProperty> > expression, BootstrapFormType formType = BootstrapFormType.Horizontal) { TModel model = htmlHelper.ViewData.Model; var expressionText = ExpressionHelper.GetExpressionText(expression); var element = new FormElementsProvider <TModel>().ExtractSingleElementFromModel(model, htmlHelper, expressionText); return(new BootStrapUIBuilder(Mode.View).BuildElement(formType, element)); }
public MvcHtmlString RenderUI(IDynamicUiBuilder <TModel> builder, BootstrapFormType formType, bool renderButtons = true) { return(builder.Build(helper.ViewData.Model, formType, renderButtons, helper)); }
public FormContainer BeginForm(string actionName, string controllerName, RouteValueDictionary routeValues, BootstrapFormType formType = BootstrapFormType.Horizontal) { return(BeginForm(actionName, controllerName, routeValues, FormMethod.Post, new RouteValueDictionary(), formType)); }
public static MvcHtmlString DynamicView <TModel>(this HtmlHelper <TModel> htmlHelper, List <FormElement> elements, BootstrapFormType formType = BootstrapFormType.Horizontal) { return(new BootStrapUIBuilder(Mode.View).BuildForm(formType, elements)); }
public MvcHtmlString DynamicView(BootstrapFormType formType = BootstrapFormType.Horizontal) { return(RenderUI(GetViewBuilder(helper), formType, false)); }
public FormContainer BeginForm(string actionName, string controllerName, FormMethod method, object htmlAttributes, BootstrapFormType formType = BootstrapFormType.Horizontal) { return(BeginForm(actionName, controllerName, new RouteValueDictionary(), method, htmlAttributes, formType)); }
public MvcHtmlString DynamicForm(BootstrapFormType formType = BootstrapFormType.Horizontal) { return(RenderUI(GetFormBuilder(), formType)); }