コード例 #1
0
 public static MvcForm AjaxBeginForm(this IHtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues, AjaxFormOptions ajaxOptions, IDictionary <string, object> htmlAttributes)
 {
     // get target URL
     return(FormHelper(htmlHelper, actionName, controllerName, ajaxOptions, htmlAttributes));
 }
コード例 #2
0
        public static MvcForm AjaxBeginForm(this IHtmlHelper htmlHelper, string actionName, string controllerName, object routeValues, AjaxFormOptions ajaxOptions, object htmlAttributes)
        {
            RouteValueDictionary newValues = new RouteValueDictionary(routeValues);
            var newAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes);

            return(AjaxBeginForm(htmlHelper, actionName, controllerName, newValues, ajaxOptions, newAttributes));
        }
コード例 #3
0
 public static MvcForm AjaxBeginForm(this IHtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues, AjaxFormOptions ajaxOptions)
 {
     return(AjaxBeginForm(htmlHelper, actionName, controllerName, routeValues, ajaxOptions, null /* htmlAttributes */));
 }
コード例 #4
0
 public static MvcForm AjaxBeginForm(this IHtmlHelper htmlHelper, string actionName, RouteValueDictionary routeValues, AjaxFormOptions ajaxOptions, IDictionary <string, object> htmlAttributes)
 {
     return(AjaxBeginForm(htmlHelper, actionName, (string)null /* controllerName */, routeValues, ajaxOptions, htmlAttributes));
 }
コード例 #5
0
 public static MvcForm AjaxBeginForm(this IHtmlHelper htmlHelper, string actionName, object routeValues, AjaxFormOptions ajaxOptions)
 {
     return(AjaxBeginForm(htmlHelper, actionName, (string)null /* controllerName */, routeValues, ajaxOptions));
 }
コード例 #6
0
        public static MvcForm AjaxBeginForm(this IHtmlHelper htmlHelper, AjaxFormOptions ajaxOptions)
        {
            string formAction = htmlHelper.ViewContext.HttpContext.Request.GetEncodedUrl();

            return(FormHelper(htmlHelper, formAction, "", ajaxOptions, new RouteValueDictionary()));
        }
コード例 #7
0
 private static AjaxFormOptions GetAjaxOptions(AjaxFormOptions ajaxOptions)
 {
     return((ajaxOptions != null) ? ajaxOptions : new AjaxFormOptions());
 }
コード例 #8
0
        //public static MvcForm BeginRouteForm(this IHtmlHelper htmlHelper, string routeName, AjaxFormOptions ajaxOptions)
        //{
        //    return BeginRouteForm(htmlHelper, routeName, null /* routeValues */, ajaxOptions, null /* htmlAttributes */);
        //}

        //public static MvcForm BeginRouteForm(this IHtmlHelper htmlHelper, string routeName, object routeValues, AjaxFormOptions ajaxOptions)
        //{
        //    return BeginRouteForm(htmlHelper, routeName, (object)routeValues, ajaxOptions, null /* htmlAttributes */);
        //}

        //public static MvcForm BeginRouteForm(this IHtmlHelper htmlHelper, string routeName, object routeValues, AjaxFormOptions ajaxOptions, object htmlAttributes)
        //{
        //    RouteValueDictionary newAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes);
        //    return BeginRouteForm(htmlHelper, routeName, new RouteValueDictionary(routeValues), ajaxOptions, newAttributes);
        //}

        //public static MvcForm BeginRouteForm(this IHtmlHelper htmlHelper, string routeName, RouteValueDictionary routeValues, AjaxFormOptions ajaxOptions)
        //{
        //    return BeginRouteForm(htmlHelper, routeName, routeValues, ajaxOptions, null /* htmlAttributes */);
        //}

        //public static MvcForm BeginRouteForm(this IHtmlHelper htmlHelper, string routeName, RouteValueDictionary routeValues, AjaxFormOptions ajaxOptions, IDictionary<string, object> htmlAttributes)
        //{
        //    string formAction = UrlHelper.GenerateUrl(routeName, null /* actionName */, null /* controllerName */, routeValues ?? new RouteValueDictionary(), htmlHelper.RouteCollection, htmlHelper.ViewContext.RequestContext, false /* includeImplicitMvcValues */);
        //    return FormHelper(htmlHelper, formAction, ajaxOptions, htmlAttributes);
        //}

        private static MvcForm FormHelper(this IHtmlHelper htmlHelper, string actionName, string controllerName, AjaxFormOptions ajaxOptions, IDictionary <string, object> htmlAttributes)
        {
            htmlAttributes = htmlAttributes ?? new Dictionary <string, object>();
            if (ajaxOptions != null)
            {
                htmlAttributes = htmlAttributes.Union(ajaxOptions.ToUnobtrusiveHtmlAttributes()).ToDictionary(c => c.Key, c => c.Value);
            }
            return(htmlHelper.BeginForm(actionName, controllerName, FormMethod.Post, htmlAttributes));
        }