public static void UpdateFormBuilderContext(this HtmlHelper htmlHelper, Action <FormBuilderContext> updateAction) { if (updateAction == null) { return; } FormBuilderContext formBuilderContext = htmlHelper.GetFormBuilderContext(); updateAction(formBuilderContext); htmlHelper.SetFormBuilderContext(formBuilderContext); }
public static FormBuilderContext GetFormBuilderContext(this HtmlHelper htmlHelper) { IDictionary items = htmlHelper.ViewContext.HttpContext.Items; FormBuilderContext builderContext = null; if (items.Contains(FormBuilderContextKey)) { builderContext = items[FormBuilderContextKey] as FormBuilderContext; } if (builderContext == null) { builderContext = new FormBuilderContext(); items[FormBuilderContextKey] = builderContext; } return(builderContext); }
public static FormBuilderContext GetFormBuilderContext(this HtmlHelper htmlHelper) { IDictionary items = htmlHelper.ViewContext.HttpContext.Items; FormBuilderContext builderContext = null; if (items.Contains(FormBuilderContextKey)) { builderContext = items[FormBuilderContextKey] as FormBuilderContext; } if (builderContext == null) { builderContext = new FormBuilderContext(); items[FormBuilderContextKey] = builderContext; } return builderContext; }
public static void SetFormBuilderContext(this HtmlHelper htmlHelper, FormBuilderContext builderContext) { htmlHelper.ViewContext.HttpContext.Items[FormBuilderContextKey] = builderContext; }