Beispiel #1
0
 /// <summary>
 /// 输出AjaxForm表单
 /// </summary>
 /// <param name="htmlHelper">被扩展的htmlHelper实例</param>
 /// <param name="actionName"></param>
 /// <param name="controllerName"></param>
 /// <param name="routeValues"></param>
 /// <param name="method">表单请求方式</param>
 /// <param name="options">异步提交表单选项</param>
 /// <returns>MvcForm</returns>
 public static MvcForm BeginAjaxForm(this HtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues, FormMethod method, AjaxFormOptions options)
 {
     return(BeginAjaxForm(htmlHelper, actionName, controllerName, routeValues, method, options, null /* htmlAttributes */));
 }
Beispiel #2
0
        /// <summary>
        /// 输出AjaxForm表单
        /// </summary>
        /// <param name="htmlHelper">被扩展的htmlHelper实例</param>
        /// <param name="actionName"></param>
        /// <param name="controllerName"></param>
        /// <param name="routeValues"></param>
        /// <param name="method">表单请求方式</param>
        /// <param name="options">异步提交表单选项</param>
        /// <param name="htmlAttributes">表单html属性集合</param>
        /// <returns>MvcForm</returns>
        public static MvcForm BeginAjaxForm(this HtmlHelper htmlHelper, string actionName, string controllerName, RouteValueDictionary routeValues, FormMethod method, AjaxFormOptions options, IDictionary <string, object> htmlAttributes)
        {
            // get target URL
            string formAction = UrlHelper.GenerateUrl(null, actionName, controllerName, routeValues ?? new RouteValueDictionary(), htmlHelper.RouteCollection, htmlHelper.ViewContext.RequestContext, true /* includeImplicitMvcValues */);

            return(FormHelper(htmlHelper, formAction, method, options, htmlAttributes));
        }
Beispiel #3
0
        /// <summary>
        /// 输出AjaxForm表单
        /// </summary>
        /// <param name="htmlHelper">被扩展的htmlHelper实例</param>
        /// <param name="actionName"></param>
        /// <param name="controllerName"></param>
        /// <param name="routeValues"></param>
        /// <param name="method">表单请求方式</param>
        /// <param name="options">异步提交表单选项</param>
        /// <param name="htmlAttributes">表单html属性集合</param>
        /// <returns>MvcForm</returns>
        public static MvcForm BeginAjaxForm(this HtmlHelper htmlHelper, string actionName, string controllerName, object routeValues, FormMethod method, AjaxFormOptions options, object htmlAttributes)
        {
            RouteValueDictionary newValues     = new RouteValueDictionary(routeValues);
            RouteValueDictionary newAttributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes);

            return(BeginAjaxForm(htmlHelper, actionName, controllerName, newValues, method, options, newAttributes));
        }
Beispiel #4
0
        /// <summary>
        /// 输出AjaxForm表单
        /// </summary>
        /// <param name="htmlHelper">被扩展的htmlHelper实例</param>
        /// <param name="formAction"></param>
        /// <param name="method">表单请求方式</param>
        /// <param name="options">异步提交表单选项</param>
        /// <param name="htmlAttributes">表单html属性集合</param>
        /// <returns>MvcForm</returns>
        private static MvcForm FormHelper(this HtmlHelper htmlHelper, string formAction, FormMethod method, AjaxFormOptions options, IDictionary <string, object> htmlAttributes)
        {
            TagBuilder builder = new TagBuilder("form");

            builder.MergeAttributes(htmlAttributes);
            if (!string.IsNullOrEmpty(formAction))
            {
                builder.MergeAttribute("action", formAction);
            }
            builder.MergeAttribute("method", HtmlHelper.GetFormMethodString(method), true);
            builder.MergeAttributes(options.ToHtmlAttributes());
            htmlHelper.ViewContext.Writer.Write(builder.ToString(TagRenderMode.StartTag));
            MvcForm theForm = new MvcForm(htmlHelper.ViewContext);

            return(theForm);
        }
Beispiel #5
0
 /// <summary>
 /// 输出AjaxForm表单
 /// </summary>
 /// <param name="htmlHelper">被扩展的htmlHelper实例</param>
 /// <param name="options">异步提交表单选项</param>
 /// <returns>MvcForm</returns>
 public static MvcForm BeginAjaxForm(this HtmlHelper htmlHelper, AjaxFormOptions options)
 {
     return(FormHelper(htmlHelper, null /* formAction */, FormMethod.Post, options, new RouteValueDictionary()));
 }
Beispiel #6
0
 /// <summary>
 /// 输出AjaxForm表单
 /// </summary>
 /// <param name="htmlHelper">被扩展的htmlHelper实例</param>
 /// <param name="routeName"></param>
 /// <param name="routeValues"></param>
 /// <param name="method">表单请求方式</param>
 /// <param name="options">异步提交表单选项</param>
 /// <returns>MvcForm</returns>
 public static MvcForm BeginAjaxRouteForm(this HtmlHelper htmlHelper, string routeName, object routeValues, FormMethod method, AjaxFormOptions options)
 {
     return(BeginAjaxRouteForm(htmlHelper, routeName, (object)routeValues, method, options, null /* htmlAttributes */));
 }
Beispiel #7
0
 /// <summary>
 /// 输出AjaxForm表单
 /// </summary>
 /// <param name="htmlHelper">被扩展的htmlHelper实例</param>
 /// <param name="action"></param>
 /// <param name="method">表单请求方式</param>
 /// <param name="options">异步提交表单选项</param>
 /// <param name="htmlAttributes">表单html属性集合</param>
 /// <returns>MvcForm</returns>
 public static MvcForm BeginAjaxForm(this HtmlHelper htmlHelper, string action, FormMethod method, AjaxFormOptions options, IDictionary <string, object> htmlAttributes)
 {
     return(FormHelper(htmlHelper, action, method, options, htmlAttributes));
 }