public static IHtmlString UploadFor(this KenticoForm html, IForm model, string controlName, IControlRenderer customRenderer) { var control = model.Controls.FirstOrDefault(ctrl => ctrl.Name.Equals(controlName, StringComparison.OrdinalIgnoreCase)); var renderedControl = customRenderer.Render(control); return(MvcHtmlString.Create(renderedControl)); }
public static IHtmlString TextBoxFor(this KenticoForm html, IControl control, IControlRenderer customRenderer) { var renderedControl = customRenderer.Render(control); return(MvcHtmlString.Create(renderedControl)); }
public static IHtmlString UploadFor(this KenticoForm html, IForm model, string controlName, object htmlAttributes) { var renderer = ControlRendererRegistrar.Resolve(ControlType.UploadFile); var control = model.Controls.FirstOrDefault(ctrl => ctrl.Name.Equals(controlName, StringComparison.OrdinalIgnoreCase)); return(MvcHtmlString.Create(renderer.Render(control, htmlAttributes))); }
public static IHtmlString BeginForm(this KenticoForm html, string action, string controllerName, string formName, string classes, ISubmissionOptions options, string method, string dataLayout, bool validate, bool summary) { var submitData = "data-submit-"; if (!string.IsNullOrEmpty(options.RedirectUrl)) { submitData += $"url=\"{options.RedirectUrl}\" "; } if (!string.IsNullOrEmpty(options.DisplayText)) { submitData += $"text=\"{options.DisplayText}\" "; } if (options.ClearAfterSave) { submitData += $"reset=\"{options.ClearAfterSave}\" "; } return(MvcHtmlString.Create($"<form action=\"/{controllerName}/{action}\" " + "entype=\"multipart/form-data\" " + $"method=\"{method}\" " + $"class=\"form form--kentico {classes}\" " + submitData + $"{(validate ? " data-validate" : string.Empty)}{(summary ? " " + "data-summary" : string.Empty)} " + $"data-layout=\"{dataLayout}\">" + $"<input type=\"hidden\" name=\"formname\" value=\"{formName}\" /> ")); }
public static IHtmlString ListBoxFor <TControl>(this KenticoForm html, TControl control, IControlRenderer customRenderer) where TControl : IControl { var renderedControl = customRenderer.Render(control); return(MvcHtmlString.Create(renderedControl.ToString())); }
public static IHtmlString UploadFor(this KenticoForm html, IForm model, string controlName) { var control = model.Controls.FirstOrDefault(ctrl => ctrl.Name.Equals(controlName, StringComparison.OrdinalIgnoreCase)); return(control != null? CalendarFor(html, control, ControlRendererRegistrar.Resolve(ControlType.UploadFile)) : MvcHtmlString.Create("")); }
public static IHtmlString SubmitButton(this KenticoForm html, string submitText, object htmlAttributes) { var tag = new MultiLevelTag("button"); tag.Attributes.Add("type", "submit"); tag.Attributes.Add("data-submit", null); tag.SetInnerText(submitText); if (htmlAttributes != null) { var customAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes); if (customAttributes != null) { foreach (var item in customAttributes.Where(item => !tag.Attributes.ContainsKey(item.Key))) { tag.Attributes.Add(item.Key, item.Value.ToString()); } } } tag.AddCssClass("button"); return(MvcHtmlString.Create(tag.ToString())); }
public static IHtmlString EndForm(this KenticoForm html) { return(MvcHtmlString.Create("</form>")); }
public static IHtmlString EditorFor <TControl>(this KenticoForm html, TControl control) where TControl : IControl { return(EditorFor <TControl>(html, control, ControlRendererRegistrar.Resolve(ControlType.HtmlArea))); }
public static IHtmlString ListBoxFor <TControl>(this KenticoForm html, TControl control) where TControl : IControl { return(ListBoxFor <TControl>(html, control, ControlRendererRegistrar.Resolve(ControlType.ListBox))); }
public static IHtmlString MultipleChoiceFor <TControl>(this KenticoForm html, TControl control) where TControl : IControl { return(MultipleChoiceFor <TControl>(html, control, ControlRendererRegistrar.Resolve(ControlType.MultipleChoice))); }
/// <summary> /// Convenience method to render a set of form fields complete with a containing label /// </summary> /// <typeparam name="TControls"></typeparam> /// <param name="model"></param> /// <param name="controls"></param> /// <returns></returns> public static IHtmlString RenderFormControls <TControls>(this KenticoForm model, TControls controls) where TControls : IList <IControl> { var result = new StringBuilder(); foreach (var control in controls) { switch (control.Type) { case ControlType.Calendar: result.AppendLine(string.Concat("<div class=\"form-row\">", model.LabelFor(control).ToHtmlString(), model.CalendarFor(control).ToHtmlString(), "</div>")); break; case ControlType.CheckBox: result.AppendLine(string.Concat("<div class=\"form-row\">", model.CheckboxFor(control).ToHtmlString(), "</div>")); break; case ControlType.DropDownList: result.AppendLine(string.Concat("<div class=\"form-row\">", model.LabelFor(control).ToHtmlString(), model.DropDownListFor(control).ToHtmlString(), "</div>")); break; case ControlType.Country: throw new NotImplementedException("Not done yet"); case ControlType.Email: result.AppendLine(string.Concat("<div class=\"form-row\">", model.LabelFor(control).ToHtmlString(), model.EmailFor(control).ToHtmlString(), "</div>")); break; case ControlType.Label: result.AppendLine(model.LabelFor(control).ToHtmlString()); break; case ControlType.ListBox: result.AppendLine(string.Concat("<div class=\"form-row\">", model.LabelFor(control).ToHtmlString(), model.ListBoxFor(control).ToHtmlString(), "</div>")); break; case ControlType.MultipleChoice: result.AppendLine(string.Concat("<div class=\"form-row\">", model.LabelFor(control).ToHtmlString(), model.MultipleChoiceFor(control).ToHtmlString(), "</div>")); break; case ControlType.RadioButton: result.AppendLine(string.Concat("<div class=\"form-row\">", model.LabelFor(control).ToHtmlString(), model.RadioButtonFor(control).ToHtmlString(), "</div>")); break; case ControlType.TextBox: result.AppendLine(string.Concat("<div class=\"form-row\">", model.LabelFor(control).ToHtmlString(), model.TextBoxFor(control).ToHtmlString(), "</div>")); break; case ControlType.TextArea: result.AppendLine(string.Concat("<div class=\"form-row\">", model.LabelFor(control).ToHtmlString(), model.TextAreaFor(control).ToHtmlString(), "</div>")); break; case ControlType.UploadFile: result.AppendLine(string.Concat("<div class=\"form-row\">", model.LabelFor(control).ToHtmlString(), model.UploadFor(control).ToHtmlString(), "</div>")); break; case ControlType.Unknown: break; default: throw new ArgumentOutOfRangeException(); } } return(MvcHtmlString.Create(result.ToString())); }
public static IHtmlString DropDownListFor <TControl>(this KenticoForm html, TControl control) where TControl : IControl { return(DropDownListFor(html, control, ControlRendererRegistrar.Resolve(ControlType.DropDownList))); }
public static IHtmlString SubmitButton(this KenticoForm html, string submitText) { return(html.SubmitButton(submitText, null)); }
public static IHtmlString EmailFor <TControl>(this KenticoForm html, TControl control, IControlRenderer renderer) where TControl : IControl { var renderedControl = renderer.Render(control); return(MvcHtmlString.Create(renderedControl)); }
public static IHtmlString CalendarFor(this KenticoForm html, IControl control) { return(CalendarFor(html, control, ControlRendererRegistrar.Resolve(ControlType.Calendar))); }
public static IHtmlString RadioButtonFor <TControl>(this KenticoForm html, TControl control) where TControl : IControl { return(RadioButtonFor <TControl>(html, control, ControlRendererRegistrar.Resolve(ControlType.RadioButton))); }
public static IHtmlString BeginForm(this KenticoForm html, string action, string controllerName, string formName, string classes, ISubmissionOptions options, string method, string dataLayout, bool validate) { return(BeginForm(html, action, controllerName, formName, classes, options, method, dataLayout, validate, false)); }
public static IHtmlString BeginForm(this KenticoForm html, string action, string controllerName, string formName, string classes, ISubmissionOptions options, string dataLayout) { return(BeginForm(html, action, controllerName, formName, classes, options, "post", dataLayout, true, false)); }
public static IHtmlString UploadFor <TControl>(this KenticoForm html, TControl control) where TControl : IControl { return(UploadFor(html, control, ControlRendererRegistrar.Resolve(ControlType.UploadFile))); }
public static IHtmlString TextAreaFor(this KenticoForm html, IControl control) { return(TextAreaFor(html, control, ControlRendererRegistrar.Resolve(ControlType.TextArea))); }
public static IHtmlString BeginForm(this KenticoForm html, string action, string controllerName, string formName, ISubmissionOptions options) { return(BeginForm(html, action, controllerName, formName, "", options, "post", "block", true, false)); }
public static IHtmlString LabelFor(this KenticoForm html, IControl control) { return(LabelFor(html, control, ControlRendererRegistrar.Resolve(ControlType.Label))); }