protected virtual TagBuilder GenerateFormCore(ViewContext viewContext, string action, Enctype enctype, string method, object htmlAttributes)
        {
            if (viewContext == null)
            {
                throw new ArgumentNullException(nameof(viewContext));
            }
            TagBuilder tagBuilder = new TagBuilder("form");
            IDictionary <string, object> dictionaryOrNull = GetHtmlAttributeDictionaryOrNull(htmlAttributes);

            tagBuilder.MergeAttributes <string, object>(dictionaryOrNull);
            string actionKey = nameof(action);

            tagBuilder.MergeAttribute(actionKey, action);
            if (string.IsNullOrEmpty(method))
            {
                method = "post";
            }
            string methodName = nameof(method);

            tagBuilder.MergeAttribute(methodName, method, true);
            string enctypeName = nameof(enctype);

            tagBuilder.MergeAttribute(enctypeName, enctype.ToLocalization(), true);
            return(tagBuilder);
        }
        public static BeginTag ToBeginForm(this HtmlRouteValueDictionary htmlAttributes, string url,
                                           JqueryAjaxOptions.HttpVerbs method = JqueryAjaxOptions.HttpVerbs.Post,
                                           Enctype enctype = Enctype.ApplicationXwwwFormUrlEncoded
                                           )
        {
            if (!htmlAttributes.ContainsKey(HtmlAttribute.Method.ToStringLower()))
            {
                htmlAttributes.Set(HtmlAttribute.Method.ToStringLower(), method.ToStringLower());
            }

            if (!htmlAttributes.ContainsKey(HtmlAttribute.Enctype.ToStringLower()))
            {
                htmlAttributes.Set(HtmlAttribute.Enctype.ToStringLower(), enctype.ToLocalization());
            }

            if (!htmlAttributes.ContainsKey(HtmlAttribute.Action.ToStringLower()))
            {
                htmlAttributes.Set(HtmlAttribute.Action.ToStringLower(), url);
            }

            return(ToBeginTag(htmlAttributes, HtmlTag.Form));
        }
        public static BeginTag ToBeginForm(this RouteValueDictionary htmlAttributes, HtmlHelper htmlHelper, string url,
                                           HttpVerbs method = HttpVerbs.Post,
                                           Enctype enctype  = Enctype.ApplicationXWWWFormUrlEncoded
                                           )
        {
            if (!htmlAttributes.ContainsKey(HtmlAttribute.Method.ToStringLower()))
            {
                htmlAttributes.Set(HtmlAttribute.Method.ToStringLower(), method.ToStringLower());
            }

            if (!htmlAttributes.ContainsKey(HtmlAttribute.Enctype.ToStringLower()))
            {
                htmlAttributes.Set(HtmlAttribute.Enctype.ToStringLower(), enctype.ToLocalization());
            }

            if (!htmlAttributes.ContainsKey(HtmlAttribute.Action.ToStringLower()))
            {
                htmlAttributes.Set(HtmlAttribute.Action.ToStringLower(), url);
            }

            return(htmlAttributes.ToBeginTag(HtmlTag.Form));
        }