public static MvcForm BeginPostForm(this AjaxHelper ajaxHelper, string url, object routeValues, string beginCallback, string successCallback, string failureCallback, string validationCallback, object htmlAttributes) { MvcForm retVal = null; beginCallback = HandledNullOrEmptyCallbacks(beginCallback); successCallback = HandledNullOrEmptyCallbacks(successCallback); failureCallback = HandledNullOrEmptyCallbacks(failureCallback); validationCallback = HandledNullOrEmptyCallbacks(validationCallback); AjaxOptions ajaxOptions = new AjaxOptions() { Url = url, HttpMethod = "POST", OnBegin = beginCallback, OnSuccess = CommonFormSubmitSuccessCallback.Replace( SuccessCallbackPlaceholder, successCallback).Replace( FailureCallbackPlaceholder, failureCallback).Replace(ValidationCallbackPlaceholder, validationCallback), OnFailure = CommonFormSubmitFailureCallback }; retVal = ajaxHelper.BeginForm(string.Empty, routeValues, ajaxOptions, htmlAttributes); return retVal; }
public static MvcForm BeginModalDialogForm(this AjaxHelper ajaxHelper) { return ajaxHelper.BeginForm(new AjaxOptions { HttpMethod = "POST" }); }
public static MvcForm BeginForm( this HtmlHelper htmlHelper, String actionName, String controllerName, Hash values ) { return htmlHelper.BeginForm(actionName, controllerName, HashHelper.ToRouteValueDictionary( values )); }
public static MvcForm BeginForm( this HtmlHelper htmlHelper, String actionName, String controllerName, FormMethod method, Hash htmlAttributes ) { return htmlHelper.BeginForm(actionName, controllerName, method, HashHelper.ToStringKeyDictinary( htmlAttributes )); }
public static MvcForm BeginForm(this HtmlHelper htmlHelper, string cssClass) { string actionName = (string)htmlHelper.ViewContext.RouteData.Values["action"]; string controllerName = (string)htmlHelper.ViewContext.RouteData.Values["controller"]; IDictionary<string, object> htmlAttributes = new Dictionary<string, object>(); htmlAttributes.Add("class", cssClass ?? string.Empty); return htmlHelper.BeginForm(actionName, controllerName, FormMethod.Post, htmlAttributes); }
public static MvcForm BeginForm(this HtmlHelper h, VMActionLink va) { if (va == null || va.Disabled) return null; var rvd = new RouteValueDictionary(); foreach (var q in va.Params.Keys) rvd.Add(q, va.Params[q]); return h.BeginForm(rvd); }
public static MvcForm AccountExternalLoginConfirmationForm(this HtmlHelper html, string returnUrl, object htmlAttributes) { return html.BeginForm( AccountController.ActionNames.ExternalLoginConfirmation, ControllerNames.Account, new {ReturnUrl = returnUrl}, FormMethod.Post, htmlAttributes); }
public static IDisposable MyBeginForm(this HtmlHelper html, string action, string controller, FormMethod method) { var routeValues = new RouteValueDictionary(); var query = html.ViewContext.HttpContext.Request.QueryString; foreach (string key in query) { routeValues[key] = query[key]; } return html.BeginForm(action, controller, routeValues, FormMethod.Get); }
/// <summary> /// Renders a <form> start tag to the response. When the user submits the form, the /// current action will process the request. /// </summary> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <param name="method">The HTTP method for processing the form, either GET or POST.</param> /// <returns> /// An <see cref="MvcForm"/> instance which renders the </form> end tag when disposed. /// </returns> /// <remarks> /// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>. /// </remarks> public static MvcForm BeginForm(this IHtmlHelper htmlHelper, FormMethod method) { if (htmlHelper == null) { throw new ArgumentNullException(nameof(htmlHelper)); } return htmlHelper.BeginForm(actionName: null, controllerName: null, routeValues: null, method: method, htmlAttributes: null); }
/// <summary> /// Renders a <form> start tag to the response. The <form>'s <c>action</c> attribute value will /// match the current request. /// </summary> /// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param> /// <returns> /// An <see cref="MvcForm"/> instance which renders the </form> end tag when disposed. /// </returns> /// <remarks> /// In this context, "renders" means the method writes its output using <see cref="ViewContext.Writer"/>. /// </remarks> public static MvcForm BeginForm(this IHtmlHelper htmlHelper) { if (htmlHelper == null) { throw new ArgumentNullException(nameof(htmlHelper)); } // Generates <form action="{current url}" method="post">. return htmlHelper.BeginForm(actionName: null, controllerName: null, routeValues: null, method: FormMethod.Post, htmlAttributes: null); }
public static MvcForm BeginForm(this BootstrapFactory factory, string actionName, string controllerName, RouteValueDictionary routeValues, Action<FormBuilder> configuration) { return factory.BeginForm(c => { var url = UrlHelper.GenerateUrl(null, actionName, controllerName, routeValues, factory.HtmlHelper.RouteCollection, factory.HtmlHelper.ViewContext.RequestContext, true); c.Url(url); if (configuration != null) configuration(c); }); }
private static MvcForm CustomBeginFormInternal(this AjaxHelper ajaxHelper, string actionName, string controllerName, object routeValues, string formName, object htmlAttributes) { var onCompleteCallback = string.Format("{0}Complete", formName); var successCallback = string.Format("{0}Success", formName); var validationErrorsCallback = string.Format("{0}ValidationErrors", formName); var onComplete = string.Format("onAjaxFormComplete(xhr, status, {0})", onCompleteCallback); var onSuccess = string.Format("onAjaxFormSuccess(data, status, xhr, {0})", successCallback); var onFailure = string.Format("onAjaxFormFailure(xhr, status, error, {0})", validationErrorsCallback); return ajaxHelper.BeginForm(actionName, controllerName, routeValues, new AjaxOptions { OnComplete = onComplete, OnSuccess = onSuccess, OnFailure = onFailure }, htmlAttributes); }
public static void GetActionForm(this HtmlHelper Html, string partialViewPath, Game game, GameActionState state, string location, object model = null) { string partialView; if (model != null) partialView = Html.Partial(partialViewPath,model).ToString(); else partialView = Html.Partial(partialViewPath).ToString(); using (Html.BeginForm("TakeGameAction", "Game", new { id = game.Id, gameAction = state, actionLocation = location }, FormMethod.Post, new { role = "form" })) { string inner = Html.AntiForgeryToken().ToString() + InsertSubmitElement(partialView); Html.ViewContext.Writer.Write(inner); } }
public static MvcForm AjaxUploadForm(this HtmlHelper htmlHelper, string actionName, string controllerName, object routeValues, AjaxOptions ajaxOptions, string errorPanel, object htmlAttributes) { ProcessOnSuccess(ajaxOptions, htmlAttributes, errorPanel, true); var newhtmlAttribute = htmlAttributes.GetType().GetProperties().ToDictionary(x => x.Name, x => x.GetValue(htmlAttributes, null)); ProcessAttributeHtmlForm(ajaxOptions, newhtmlAttribute); newhtmlAttribute.Add("enctype", "multipart/form-data"); var newRouteCollection = new RouteValueDictionary(); foreach (var prop in routeValues.GetType().GetProperties()) { newRouteCollection.Add(prop.Name, prop.GetValue(routeValues, null)); } return htmlHelper.BeginForm(actionName, controllerName, newRouteCollection, FormMethod.Post, newhtmlAttribute); }
public static MvcForm BeginForm(this HtmlHelper html, string controllerName = null, string actionName = null, object routeValues = null, FormMethod method = FormMethod.Post, string cssClass = "", object htmlAttributes = null) { var routeDictionary = new RouteValueDictionary(routeValues); var htmlAttibutesDictionary = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes); return html.BeginForm(controllerName: controllerName, actionName: actionName, routeValues: routeDictionary, method: method, cssClass: cssClass, htmlAttributes: htmlAttibutesDictionary); }
public static MvcForm SackForm(this AjaxHelper helper, [AspMvcAction] string action, [AspMvcController] string controller, object routeValues, string loader, object htmlAttributes = null, string formId = null) { var guid = formId??helper.Cs().GetUniqueId(); var ajaxOptions = new AjaxOptions { AllowCache = false, HttpMethod = "Post", InsertionMode = InsertionMode.Replace, LoadingElementId = loader, LoadingElementDuration = 200, UpdateTargetId = guid, OnSuccess = $"$.validator.unobtrusive.parse($('#{guid}'));" }; var attributes = htmlAttributes != null ? HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes) : new RouteValueDictionary(); var routeVals = routeValues != null ? HtmlHelper.AnonymousObjectToHtmlAttributes(routeValues) : new RouteValueDictionary(); attributes.Add("id", guid); var beginForm = helper.BeginForm(action, controller, routeVals, ajaxOptions, attributes); return beginForm; }
public static string ConfirmableActionLink(this HtmlHelper helper, string label, string message, string action, object routeValues, string controller, FormMethod formMethod) { var uniqueId = Guid.NewGuid().ToString().Replace("-", ""); var scriptTag = new TagBuilder("script"); scriptTag.Attributes.Add("type", "text/javascript"); scriptTag.InnerHtml = "$(function(){ $('#" + uniqueId + "').confirmableActionLink('" + message.Replace("'", "\'") + "'); });"; var submitButton = new TagBuilder("input"); submitButton.AddCssClass("confirmableActionLink"); submitButton.Attributes.Add("id", uniqueId); submitButton.Attributes.Add("type", "submit"); submitButton.Attributes.Add("value", label); helper.ViewContext.Writer.Write(scriptTag.ToString()); using (helper.BeginForm(action, controller, routeValues, formMethod)) { helper.ViewContext.Writer.Write(helper.AntiForgeryToken()); helper.ViewContext.Writer.Write(submitButton.ToString()); } return ""; }
public static MvcForm BeginForm(this AjaxHelper ajaxHelper, string actionName, string controllerName, object routeValues, AjaxOptions ajaxOptions, string errorPanel, object htmlAttributes) { if (!string.IsNullOrEmpty(errorPanel)) { ProcessOnSuccess(ajaxOptions, htmlAttributes, errorPanel); } ProcessOnFailure(ajaxOptions, htmlAttributes); var newhtmlAttribute = htmlAttributes.GetType().GetProperties().ToDictionary(x => x.Name, x => x.GetValue(htmlAttributes, null)); if (newhtmlAttribute.ContainsKey("class")) newhtmlAttribute["class"] = newhtmlAttribute["class"] + " ajax-form"; else newhtmlAttribute.Add("class", "ajax-form"); var newRouteCollection = new RouteValueDictionary(); if (routeValues != null) { foreach (var prop in routeValues.GetType().GetProperties()) { newRouteCollection.Add(prop.Name, prop.GetValue(routeValues, null)); } } return ajaxHelper.BeginForm(actionName, controllerName, newRouteCollection, ajaxOptions, newhtmlAttribute); }
/// <summary> /// Begins the horizontal form. /// </summary> /// <param name="helper">The helper.</param> /// <param name="routeValues">The route values.</param> /// <returns></returns> public static MvcForm BeginHorizontalForm(this HtmlHelper helper, object routeValues) { return helper.BeginForm(null, null, routeValues, FormMethod.Post, new { @class = "form-horizontal", role = "form" }); }
public static MvcForm BeginForm(this HtmlHelper htmlHelper, ActionResult result, FormMethod formMethod, IDictionary<string, object> htmlAttributes) { var callInfo = result.GetT4MVCResult(); return htmlHelper.BeginForm(callInfo.Action, callInfo.Controller, callInfo.RouteValueDictionary, formMethod, htmlAttributes); }
public static MvcForm BeginFormWithCloseDialog(this AjaxHelper ajaxHelper, string actionName, string controllerName, object routeValues, AjaxOptions ajaxOptions, string errorPanel, object htmlAttributes) { ProcessOnComplete(ajaxOptions); return ajaxHelper.BeginForm(actionName, controllerName, routeValues, ajaxOptions, errorPanel, htmlAttributes); }
public static MvcForm BeginForm(this HtmlHelper htmlHelper, ActionResult result) { return htmlHelper.BeginForm(result, FormMethod.Post); }
public static MvcForm BeginForm(this HtmlHelper htmlHelper, ActionResult result, FormMethod formMethod) { return htmlHelper.BeginForm(result, formMethod, null); }
public static MvcForm BeginForm(this AjaxHelper ajaxHelper, ActionResult result, AjaxOptions ajaxOptions) { return ajaxHelper.BeginForm(result, ajaxOptions, null); }
public static MvcForm BeginForm(this AjaxHelper ajaxHelper, ActionResult result, AjaxOptions ajaxOptions, IDictionary<string, object> htmlAttributes) { var callInfo = result.GetT4MVCResult(); return ajaxHelper.BeginForm(callInfo.Action, callInfo.Controller, callInfo.RouteValueDictionary, ajaxOptions, htmlAttributes); }
public static SecurityTrimmingForm BeginSecurityTrimmingForm(this HtmlHelper htmlHelper, string actionName, string controllerName = null) { Func<MvcForm> lazyForm = () => htmlHelper.BeginForm(actionName, controllerName); return new SecurityTrimmingForm(htmlHelper, lazyForm, actionName, controllerName); }
public static MvcForm BeginBootstrapForm(this HtmlHelper helper, object routeValues) { return helper.BeginForm(null, null, routeValues, FormMethod.Post, new { role = "form" }); }
/// <summary> /// Renders a form suitable for BForms fields /// </summary> public static BsMvcForm BsBeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues, FormMethod method, IDictionary<string, object> htmlAttributes, BsTheme theme) { var form = htmlHelper.BeginForm(actionName, controllerName, routeValues, method, htmlAttributes); var tag = new TagBuilder("div"); tag.AddCssClass("row"); tag.AddCssClass("form_container"); tag.AddCssClass("loading"); tag.AddCssClass(theme.GetDescription()); var myForm = new BsMvcForm(htmlHelper.ViewContext, form, tag.ToString(TagRenderMode.StartTag), tag.ToString(TagRenderMode.EndTag)); return myForm; }
public static MvcForm BeginForm( this HtmlHelper htmlHelper, Hash values ) { return htmlHelper.BeginForm(HashHelper.ToRouteValueDictionary( values )); }
/// <summary> /// The begin modal dialog form. /// </summary> /// <param name="ajaxHelper">The ajax helper.</param> /// <returns>The <see cref="MvcForm"/>.</returns> public static MvcForm BeginModalDialogForm(this AjaxHelper ajaxHelper) { // ReSharper disable once Mvc.ActionNotResolved return ajaxHelper.BeginForm(new AjaxOptions { HttpMethod = "POST" }); }