/// <summary> /// Generates the Form preamble /// </summary> /// <param name="ajax"></param> /// <param name="controllerName"></param> /// <param name="routeValues"></param> /// <param name="ajaxOptions"></param> /// <param name="actionType"></param> /// <returns></returns> public static MvcForm BeginResourceForm(this AjaxHelper ajax, string controllerName, object routeValues, AjaxOptions ajaxOptions, ActionType actionType) { switch (actionType) { case ActionType.GetUpdateForm: return(ajax.BeginRouteForm(controllerName + "-editForm", routeValues, ajaxOptions)); case ActionType.GetCreateForm: return(ajax.BeginRouteForm(controllerName + "-createForm", ajaxOptions)); case ActionType.Retrieve: case ActionType.Delete: case ActionType.Update: // can we use ajaxOptions to either add the header? MvcForm form = ajax.BeginRouteForm(controllerName, routeValues, ajaxOptions); return(form); case ActionType.Create: return(ajax.BeginRouteForm(controllerName + "-create", ajaxOptions)); case ActionType.Index: return(ajax.BeginRouteForm(controllerName + "-index", ajaxOptions)); default: throw new ArgumentOutOfRangeException("actionType"); } }
public AjaxContactForm(AjaxHelper ajaxHelper, PagePayload page, AjaxOptions ajaxOptions, object formAttributes = null) { _helper = ajaxHelper; if (page == null) { page = PagePayload.GetCurrentContent(); } if (ajaxOptions == null) { ajaxOptions = new AjaxOptions(); ajaxOptions.InsertionMode = InsertionMode.Replace; } if (String.IsNullOrEmpty(ajaxOptions.HttpMethod)) { ajaxOptions.HttpMethod = "POST"; } if (String.IsNullOrEmpty(ajaxOptions.UpdateTargetId)) { ajaxOptions.UpdateTargetId = "frmContact"; } if (String.IsNullOrEmpty(ajaxOptions.OnFailure)) { ajaxOptions.OnFailure = "__OnAjaxRequestFailure"; } string formAction = "Contact.ashx"; //try #3 //RouteValueDictionary dic = new RouteValueDictionary(); //dic.Add("controller", "CmsAjaxForms"); //dic.Add("action", formAction); //if (SecurityData.AdvancedEditMode) { // dic.Add(SiteData.AdvancedEditParameter, true); //} //frm = ajaxHelper.BeginRouteForm("Default", dic, ajaxOptions, formAttributes); //try #2 if (SecurityData.AdvancedEditMode) { frm = ajaxHelper.BeginRouteForm("Default", new { controller = "CmsAjaxForms", action = formAction, carrotedit = true }, ajaxOptions, formAttributes); } else { frm = ajaxHelper.BeginRouteForm("Default", new { controller = "CmsAjaxForms", action = formAction }, ajaxOptions, formAttributes); } /* * //try #1 * string formAction = "Contact.ashx"; * FormRouteValue frv = new FormRouteValue("CmsAjaxForms", formAction); * * if (SecurityData.AdvancedEditMode) { * frv = new FormRouteValue("CmsAjaxForms", formAction, true); * } * * frm = ajaxHelper.BeginRouteForm("Default", frv, ajaxOptions, formAttributes); */ }
private static MvcForm GenerateForm(this HtmlHelper htmlHelper, string formAction, FormMethod method, IDictionary <string, object> htmlAttributes, FormLayout layout) { var tagBuilder = new TagBuilder("form"); tagBuilder.MergeAttributes(htmlAttributes); tagBuilder.MergeAttribute("action", formAction); tagBuilder.MergeAttribute("method", HtmlHelper.GetFormMethodString(method), true); if (layout != FormLayout.Default) { tagBuilder.AddCssClass("form-" + layout.ToString().ToLower()); } htmlHelper.ViewContext.TempData["BootstrapFormLayout"] = layout; var flag = htmlHelper.ViewContext.ClientValidationEnabled && !htmlHelper.ViewContext.UnobtrusiveJavaScriptEnabled; if (flag) { tagBuilder.GenerateId(GenerateId(htmlHelper.ViewContext)); } htmlHelper.ViewContext.Writer.Write(tagBuilder.ToString(TagRenderMode.StartTag)); var mvcForm = new MvcForm(htmlHelper.ViewContext); if (flag) { htmlHelper.ViewContext.FormContext.FormId = tagBuilder.Attributes["id"]; } return(mvcForm); }
/// <summary> /// SiForm -- zhangh 2013/06/13 /// </summary> /// <param name="htmlHelper"></param> /// <param name="controllerName"></param> /// <param name="actionName"></param> /// <param name="method"></param> /// <param name="htmlAttributes"></param> /// <returns></returns> public static MvcForm SiForm(this HtmlHelper htmlHelper, string controllerName, string actionName, FormMethod method, object htmlAttributes) { TagBuilder tagBuilder = new TagBuilder("form"); if (htmlAttributes != null) { tagBuilder.MergeAttributes(new RouteValueDictionary(htmlAttributes)); } tagBuilder.AddCssClass("si-form"); tagBuilder.MergeAttribute("controller", controllerName); tagBuilder.MergeAttribute("action", actionName); tagBuilder.MergeAttribute("method", HtmlHelper.GetFormMethodString(method), true); bool traditionalJavascriptEnabled = htmlHelper.ViewContext.ClientValidationEnabled && !htmlHelper.ViewContext.UnobtrusiveJavaScriptEnabled; htmlHelper.ViewContext.Writer.Write(tagBuilder.ToString(TagRenderMode.StartTag)); MvcForm theForm = new MvcForm(htmlHelper.ViewContext); if (traditionalJavascriptEnabled) { htmlHelper.ViewContext.FormContext.FormId = tagBuilder.Attributes["id"]; } return(theForm); }
private static MvcForm FormHelper(this AjaxHelper ajaxHelper, string formAction, AjaxOptions ajaxOptions, IDictionary <string, object> htmlAttributes) { TagBuilder builder = new TagBuilder("form"); builder.MergeAttributes(htmlAttributes); builder.MergeAttribute("action", formAction); builder.MergeAttribute("method", "post"); builder.MergeAttribute("onclick", FormOnClickValue); builder.MergeAttribute("onsubmit", GenerateAjaxScript(GetAjaxOptions(ajaxOptions), FormOnSubmitFormat)); if (ajaxHelper.ViewContext.ClientValidationEnabled) { // forms must have an ID for client validation builder.GenerateId(ajaxHelper.ViewContext.FormIdGenerator()); } ajaxHelper.ViewContext.Writer.Write(builder.ToString(TagRenderMode.StartTag)); MvcForm theForm = new MvcForm(ajaxHelper.ViewContext); if (ajaxHelper.ViewContext.ClientValidationEnabled) { ajaxHelper.ViewContext.FormContext.FormId = builder.Attributes["id"]; } return(theForm); }
public void BeginFormWithClientValidationEnabled() { // Arrange StringWriter writer; HtmlHelper htmlHelper = GetFormHelper(out writer); htmlHelper.ViewContext.ClientValidationEnabled = true; htmlHelper.ViewContext.FormContext = null; FormContext defaultFormContext = htmlHelper.ViewContext.FormContext; // Act & assert - push MvcForm theForm = htmlHelper.BeginForm(); Assert.NotNull(htmlHelper.ViewContext.FormContext); Assert.NotEqual(defaultFormContext, htmlHelper.ViewContext.FormContext); Assert.Equal("form_id", htmlHelper.ViewContext.FormContext.FormId); // Act & assert - pop theForm.Dispose(); Assert.Equal(defaultFormContext, htmlHelper.ViewContext.FormContext); Assert.Equal(@"<form action=""/some/path"" id=""form_id"" method=""post""></form><script type=""text/javascript""> //<![CDATA[ if (!window.mvcClientValidationMetadata) { window.mvcClientValidationMetadata = []; } window.mvcClientValidationMetadata.push({""Fields"":[],""FormId"":""form_id"",""ReplaceValidationSummary"":false}); //]]> </script>", writer.ToString()); }
private static MvcForm FormHelper(this AjaxHelper ajaxHelper, string formId, string formAction, bool isAjax, string callback, string cssClassNames, IDictionary <string, object> htmlAttributes) { var tagBuilder = new TagBuilder("form"); tagBuilder.MergeAttributes(htmlAttributes); tagBuilder.MergeAttribute("action", formAction); tagBuilder.MergeAttribute("method", @"post"); var metadataBuilder = new System.Text.StringBuilder(); metadataBuilder.AppendFormat("isAjax: {0}", isAjax.ToJavascriptString()); if (!string.IsNullOrEmpty(callback)) { metadataBuilder.AppendFormat(", callback: '{0}'", callback); } var metadata = "{" + metadataBuilder.ToString() + "}"; tagBuilder.Attributes["data-options"] = metadata; tagBuilder.MergeAttribute("autocomplete", @"off"); tagBuilder.MergeAttribute("class", "jqAjaxForm " + (!string.IsNullOrEmpty(cssClassNames) ? cssClassNames : string.Empty)); tagBuilder.GenerateId(formId); ajaxHelper.ViewContext.Writer.Write(tagBuilder.ToString(TagRenderMode.StartTag)); var form = new MvcForm(ajaxHelper.ViewContext); if (ajaxHelper.ViewContext.ClientValidationEnabled) { ajaxHelper.ViewContext.FormContext.FormId = tagBuilder.Attributes["id"]; } return(form); }
public void BeginFormWithClientValidationEnabled() { // Arrange StringWriter writer; HtmlHelper htmlHelper = GetFormHelper(out writer); FormContext originalContext = new FormContext(); htmlHelper.ViewContext.ClientValidationEnabled = true; htmlHelper.ViewContext.FormContext = originalContext; // Act & assert - push MvcForm theForm = htmlHelper.BeginForm(); Assert.IsNotNull(htmlHelper.ViewContext.FormContext); Assert.AreNotEqual(originalContext, htmlHelper.ViewContext.FormContext, "FormContext should have been set to a new instance."); Assert.AreEqual("form_id", htmlHelper.ViewContext.FormContext.FormId); // Act & assert - pop theForm.Dispose(); Assert.AreEqual(originalContext, htmlHelper.ViewContext.FormContext, "FormContext was not properly restored."); Assert.AreEqual(@"<form action=""/some/path"" id=""form_id"" method=""post""></form><script type=""text/javascript""> //<![CDATA[ if (!window.mvcClientValidationMetadata) { window.mvcClientValidationMetadata = []; } window.mvcClientValidationMetadata.push({""Fields"":[],""FormId"":""form_id"",""ReplaceValidationSummary"":false}); //]]> </script>", writer.ToString()); }
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); }
private static MvcForm FormHelper(this HtmlHelper htmlHelper, string formAction, FormMethod method, IDictionary <string, object> htmlAttributes) { TagBuilder tagBuilder = new TagBuilder("form"); tagBuilder.MergeAttributes(htmlAttributes); // action is implicitly generated, so htmlAttributes take precedence. tagBuilder.MergeAttribute("action", formAction); // method is an explicit parameter, so it takes precedence over the htmlAttributes. tagBuilder.MergeAttribute("method", HtmlHelper.GetFormMethodString(method), true); bool traditionalJavascriptEnabled = htmlHelper.ViewContext.ClientValidationEnabled && !htmlHelper.ViewContext.UnobtrusiveJavaScriptEnabled; if (traditionalJavascriptEnabled) { // forms must have an ID for client validation //tagBuilder.GenerateId(htmlHelper.ViewContext.FormIdGenerator()); } htmlHelper.ViewContext.Writer.Write(tagBuilder.ToString(TagRenderMode.StartTag)); //htmlHelper.ViewContext.Writer.Write(htmlHelper.AntiForgeryToken().ToHtmlString()); htmlHelper.ViewContext.Writer.Write(htmlHelper.Hidden("__RequestVerificationToken", "value")); MvcForm theForm = new MvcForm(htmlHelper.ViewContext); if (traditionalJavascriptEnabled) { htmlHelper.ViewContext.FormContext.FormId = tagBuilder.Attributes["id"]; } return(theForm); }
public DynamicMvcForm(ViewContext viewContext, MvcForm mvcForm, DynamicForm dynamicForm, T data) : base(viewContext) { _viewContext = viewContext; _mvcForm = mvcForm; _dynamicForm = dynamicForm; _data = data; }
public ExampleConfigurator PostTo(string action, string controller) { string theme = this.htmlHelper.ViewContext.HttpContext.Request.Params["theme"] ?? "vista"; this.form = this.htmlHelper.BeginForm(action, controller, new { theme = theme }); return(this); }
/// <summary> /// HTML Form wrapper /// </summary> /// <param name="startTags">html content injected after begin form</param> /// <param name="endTags">html content injected before end form</param> public BsMvcForm(ViewContext viewContext, MvcForm form, string startTags = null, string endTags = null) { _form = form; _endTags = endTags; _viewContext = viewContext; if (!string.IsNullOrEmpty(startTags)) { _viewContext.Writer.Write(startTags); } }
public void EndFormRendersCloseFormTag() { // Arrange Mock <HttpResponseBase> mockHttpResponse = GetHttpResponseForForm(); MvcForm form = new MvcForm(mockHttpResponse.Object); // Act form.EndForm(); // Assert mockHttpResponse.Verify(); }
public void DisposeTwiceRendersCloseFormTagOnce() { // Arrange Mock <HttpResponseBase> mockHttpResponse = GetHttpResponseForForm(); MvcForm form = new MvcForm(mockHttpResponse.Object); // Act form.Dispose(); form.Dispose(); // Assert mockHttpResponse.Verify(); }
public static IDisposable BeginAjaxContentValidation(this HtmlHelper html, string formId) { MvcForm mvcForm = null; if (html.ViewContext.FormContext == null) { html.EnableClientValidation(); mvcForm = new MvcForm(html.ViewContext); html.ViewContext.FormContext.FormId = formId; } return(new AjaxContentValidation(html.ViewContext, mvcForm)); }
public void EndFormRendersCloseFormTag() { // Arrange StringWriter writer = new StringWriter(); ViewContext viewContext = GetViewContext(writer); MvcForm form = new MvcForm(viewContext); // Act form.EndForm(); // Assert Assert.Equal("</form>", writer.ToString()); }
public static MvcForm BeginanLasschotForm(this HtmlHelper htmlHelper, string formId) { var rawUrl = htmlHelper.ViewContext.HttpContext.Request.RawUrl; var tagBuilder = new TagBuilder("form"); tagBuilder.MergeAttribute("id", formId); tagBuilder.MergeAttribute("action", rawUrl); tagBuilder.MergeAttribute("method", HtmlHelper.GetFormMethodString(FormMethod.Post), true); htmlHelper.ViewContext.Writer.Write(tagBuilder.ToString(TagRenderMode.StartTag)); var mvcForm = new MvcForm(htmlHelper.ViewContext); htmlHelper.ViewContext.FormContext.FormId = tagBuilder.Attributes["id"]; return(mvcForm); }
public void EndFormRendersCloseFormTag() { // Arrange StringWriter writer = new StringWriter(); ViewContext viewContext = GetViewContext(writer); MvcForm form = new MvcForm(viewContext); // Act form.EndForm(); // Assert Assert.Equal("</form>", writer.ToString()); }
public void DisposeTwiceRendersCloseFormTagOnce() { // Arrange StringWriter writer = new StringWriter(); ViewContext viewContext = GetViewContext(writer); MvcForm form = new MvcForm(viewContext); // Act form.Dispose(); form.Dispose(); // Assert Assert.AreEqual("</form>", writer.ToString()); }
private void Init(HtmlHelper html, string actionName = null, string controllerName = null, object routeValues = null, FormMethod method = FormMethod.Post, object htmlAttrs = null, FormType?formType = null) { var attrs = new HtmlAttributes(htmlAttrs); if (formType != null) { attrs["class"] += "form-" + formType.ToString().ToLower(); } if (html == null) { return; } _form = html.BeginForm(actionName, controllerName, new RouteValueDictionary(routeValues), method, attrs.ToDictionary()); }
private static MvcForm FormHelper(this HtmlHelper htmlHelper, string formAction, FormMethod method, IDictionary <string, object> htmlAttributes) { TagBuilder tagBuilder = new TagBuilder("form"); tagBuilder.MergeAttributes(htmlAttributes); // action is implicitly generated, so htmlAttributes take precedence. tagBuilder.MergeAttribute("action", formAction); // method is an explicit parameter, so it takes precedence over the htmlAttributes. tagBuilder.MergeAttribute("method", HtmlHelper.GetFormMethodString(method), true); htmlHelper.ViewContext.Writer.Write(tagBuilder.ToString(TagRenderMode.StartTag)); MvcForm theForm = new MvcForm(htmlHelper.ViewContext); return(theForm); }
/// <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) + htmlHelper.AntiForgeryToken()); MvcForm theForm = new MvcForm(htmlHelper.ViewContext); return(theForm); }
public void BeginFormWithClientValidationAndUnobtrusiveJavaScriptEnabled() { // Arrange StringWriter writer; HtmlHelper htmlHelper = GetFormHelper(out writer); htmlHelper.ViewContext.ClientValidationEnabled = true; htmlHelper.ViewContext.UnobtrusiveJavaScriptEnabled = true; // Act & assert - push MvcForm theForm = htmlHelper.BeginForm(); Assert.Null(htmlHelper.ViewContext.FormContext.FormId); // Act & assert - pop theForm.Dispose(); Assert.Equal(@"<form action=""/some/path"" method=""post""></form>", writer.ToString()); }
public void BeginFormSetsAndRestoresFormContext() { // Arrange AjaxHelper ajaxHelper = GetAjaxHelper(); FormContext originalContext = new FormContext(); ajaxHelper.ViewContext.FormContext = originalContext; // Act & assert - push MvcForm theForm = ajaxHelper.BeginForm(new AjaxOptions()); Assert.IsNotNull(ajaxHelper.ViewContext.FormContext); Assert.AreNotEqual(originalContext, ajaxHelper.ViewContext.FormContext, "FormContext should have been set to a new instance."); // Act & assert - pop theForm.Dispose(); Assert.AreEqual(originalContext, ajaxHelper.ViewContext.FormContext, "FormContext was not properly restored."); }
public static MvcForm FJBeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, bool hasFile, FormMethod formMethod, bool hasFakeAjax, object htmlAttributes) { IDictionary <string, object> attributes = GetHtmlAttributes(htmlAttributes); if (hasFakeAjax) { attributes.Add("target", "HiddenIframe"); } // 是否有檔案上傳 if (hasFile) { attributes.Add("enctype", "multipart/form-data"); } MvcForm mvcForm = htmlHelper.BeginForm(actionName, controllerName, formMethod, attributes); return(mvcForm); }
public static MvcForm BeginSecureForm(this HtmlHelper htmlHelper, string actionName, string controllerName, FormMethod method, object htmlAttributes) { TagBuilder tagBuilder = new TagBuilder("form"); Dictionary <string, object> htmlAttributesDictionary = new Dictionary <string, object>(); foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(htmlAttributes)) { htmlAttributesDictionary.Add(property.Name, property.GetValue(htmlAttributes)); } tagBuilder.MergeAttributes(htmlAttributesDictionary); tagBuilder.MergeAttribute("action", UrlHelper.GenerateUrl(null, actionName, controllerName, new RouteValueDictionary(), htmlHelper.RouteCollection, htmlHelper.ViewContext.RequestContext, true)); tagBuilder.MergeAttribute("method", HtmlHelper.GetFormMethodString(method), true); htmlHelper.ViewContext.Writer.Write(tagBuilder.ToString(TagRenderMode.StartTag)); htmlHelper.ViewContext.Writer.Write(htmlHelper.AntiForgeryToken().ToHtmlString()); var theForm = new MvcForm(htmlHelper.ViewContext); return(theForm); }
public void BeginFormSetsAndRestoresToDefault() { // Arrange StringWriter writer; HtmlHelper htmlHelper = GetFormHelper(out writer); htmlHelper.ViewContext.FormContext = null; FormContext defaultFormContext = htmlHelper.ViewContext.FormContext; // Act & assert - push MvcForm theForm = htmlHelper.BeginForm(); Assert.NotNull(htmlHelper.ViewContext.FormContext); Assert.NotEqual(defaultFormContext, htmlHelper.ViewContext.FormContext); // Act & assert - pop theForm.Dispose(); Assert.Equal(defaultFormContext, htmlHelper.ViewContext.FormContext); Assert.Equal(@"<form action=""/some/path"" method=""post""></form>", writer.ToString()); }
public void BeginFormSetsAndRestoresFormContext() { // Arrange StringWriter writer; HtmlHelper htmlHelper = GetFormHelper(out writer); FormContext originalContext = new FormContext(); htmlHelper.ViewContext.FormContext = originalContext; // Act & assert - push MvcForm theForm = htmlHelper.BeginForm(); Assert.IsNotNull(htmlHelper.ViewContext.FormContext); Assert.AreNotEqual(originalContext, htmlHelper.ViewContext.FormContext, "FormContext should have been set to a new instance."); // Act & assert - pop theForm.Dispose(); Assert.AreEqual(originalContext, htmlHelper.ViewContext.FormContext, "FormContext was not properly restored."); Assert.AreEqual(@"<form action=""/some/path"" method=""post""></form>", writer.ToString()); }
public AjaxResetPasswordForm(AjaxHelper ajaxHelper, PagePayload page, AjaxOptions ajaxOptions, object formAttributes = null) { _helper = ajaxHelper; if (page == null) { page = PagePayload.GetCurrentContent(); } if (ajaxOptions == null) { ajaxOptions = new AjaxOptions(); ajaxOptions.InsertionMode = InsertionMode.Replace; } if (String.IsNullOrEmpty(ajaxOptions.HttpMethod)) { ajaxOptions.HttpMethod = "POST"; } if (String.IsNullOrEmpty(ajaxOptions.UpdateTargetId)) { ajaxOptions.UpdateTargetId = "frmResetPassword"; } if (String.IsNullOrEmpty(ajaxOptions.OnFailure)) { ajaxOptions.OnFailure = "__OnAjaxRequestFailure"; } string code = ResetPasswordInfoSettings.CodeUrl; string formAction = "ResetPassword.ashx"; if (SecurityData.AdvancedEditMode) { frm = ajaxHelper.BeginRouteForm("Default", new { controller = "CmsAjaxForms", action = formAction, @code = code, @carrotedit = true }, ajaxOptions, formAttributes); } else { frm = ajaxHelper.BeginRouteForm("Default", new { controller = "CmsAjaxForms", action = formAction, @code = code }, ajaxOptions, formAttributes); } }
private static MvcForm FormHelper(HtmlHelper htmlHelper, string formAction, FormMethod method, IDictionary <string, object> htmlAttributes) { TagBuilder builder = new TagBuilder("form"); builder.MergeAttributes <string, object>(htmlAttributes); builder.MergeAttribute("action", formAction); builder.MergeAttribute("method", HtmlHelper.GetFormMethodString(method), true); bool flag = htmlHelper.ViewContext.ClientValidationEnabled && !htmlHelper.ViewContext.UnobtrusiveJavaScriptEnabled; if (flag) { builder.GenerateId(htmlHelper.ViewContext.FormIdGenerator()); } htmlHelper.ViewContext.Writer.Write(builder.ToString(TagRenderMode.StartTag)); MvcForm form = new MvcForm(htmlHelper.ViewContext); if (flag) { htmlHelper.ViewContext.FormContext.FormId = builder.Attributes["id"]; } return(form); }