But my contact form by using Html.BeginnUmbracoForm don't call this action. I don't know why I can call the action from url, but why the partial view not call this action If I click on the submit button.
Model:
namespace UmbracoWebsite.Logic
{
public class ContactFormModel
{
[Required]
public string Name { get; set; }
[Required]
[EmailAddress]
public string Email { get; set; }
[Required]
public string Betreff { get; set; }
[Required]
public string Mitteilung { get; set; }
}
}
Controller:
namespace UmbracoWebsite.Logic
{
public class ContactFormController : SurfaceController
{
[AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)]
[ValidateAntiForgeryToken]
[ChildActionOnly]
public ActionResult Submit(ContactFormModel model)
{
if (model.Name == "Sören")
{
return Content("True", "application/json");
} else
{
return Content("False", "application/json");
}
}
}
}
Html.BeginUmbracoForm will automatically generate the <form> element, so since you've also added your own <form> element, it prevents the form from submitting correctly.
If you remove your own <form> element, the form is successfully submitted to the controller ;)
Html.BeginnUmbracoForm not call SurfaceController Action
Hi Umbracians,
I have the following problem: If I call my Surface Action directly per URL in Browser the action is found:
http://localhost:55759/umbraco/surface/contactForm/submit
But my contact form by using Html.BeginnUmbracoForm don't call this action. I don't know why I can call the action from url, but why the partial view not call this action If I click on the submit button.
Model:
Controller:
PartialView:
I'm using Umbraco v7.7.7.
Have anyone an idea to solve this?
Best, Sören
Hi Sören,
Html.BeginUmbracoForm
will automatically generate the<form>
element, so since you've also added your own<form>
element, it prevents the form from submitting correctly.If you remove your own
<form>
element, the form is successfully submitted to the controller ;)Hi Anders,
of course, this works! It was too late last evenig ;-) Thank you and I wish you a merry christmas.
Best, Sören
is working on a reply...