New UmbracoForms (not Contour) AJAX call

2019-09-09 01:15发布

问题:

Update: The project has been started that should amend most, if not all, the problems UmbracoForms have (including AJAX calls). The discussion started on this forum thread: our.umbraco.org/forum/umbraco-7/developing-umbraco-7-packages/69933-replacing-contour-umbraco-forms-with-something-better. The website for the solution is: www.formulate.rocks and expected release date is 'early 2016' as stated on their website.

Original post:

I am trying to make an Ajax call with new UmbracoForms, but so far without success. The issue I am experiencing is described in the following OUR Umbraco forum post.

The problem is related with the modification of custom 'Form.cshtml'. Current implementation uses the following HTML helper:

@using (Html.BeginUmbracoForm<Umbraco.Forms.Web.Controllers.UmbracoFormsController>("HandleForm"))

This causes a post back to the page, which is a problem since the form on the website is being displayed in modal/overlay window.

I have tried the following two implementations:

First:

@using (Ajax.BeginForm("UmbracoForms", "HandleForm", new AjaxOptions 
                                                     {
                                                      HttpMethod = "POST",
                                                      OnSuccess = "Success()",
                                                      OnFailure = "Failure()"
                                                     }))

Second:

@using (Html.BeginForm("HandleForm", "UmbracoForms", FormMethod.Post, new { enctype = "multipart/form-data", role = "form" }))

There is additional information on the Umbraco forum page I have referenced, and also there is my comment at the bottom of the post with the described issue.