Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Been a long day!
Cannot get this to run, now tired and need a bit of friendly Umbraco Community assistance, please-
Ok have controller
Trying to get the form to render using
@Html.Action("SendMail" , "ContactSurface")
The error is " A public action method Send Mail was not found on controller G04_733.Controllers.ContactSurfaceController.
So, it's finding the controller, but what is wrong I can't seem to figure.
Really hope it's something simple - would be really happy to finish this soon.
Thanks in advance
will attempt to write out a 'Child Action' called SendMail on the ContactSurfaceController Surface Controller
public ActionResult SendMail()
but in your screenshot above you have a SendMail action marked as only accepting a 'post' verb.
Your view is using BeginUmbracoForm and is wired to post to an action called 'HandleContactForm' in your ContactSurfaceController - does that action exist ? or should it be posting to 'SendMail' ?
You can create a child action on your surface controller to write out your partial view or you can render your partial view containing your form directly from a template, in this way:
@Html.Partial("~/Views/Partials/YourLoginView.cshtml", new ContactViewModel());
In your surface controller there are also two special helpers you can use: CurrentUmbracoPage to return to the Umbraco current page and keep the modelstate intact or use RedirectToCurrentUmbracoPage to clear the modelstate and return to the current page.
ModelState.AddModelError("", "you can add custom error messages to modelstate");
if that helps ?
Thank you so much for taking the time to help. Apologies for taking so long to reply.
Will have another look at this tomorrow and will for sure be using your ideas.
Just curious, I saw this method of a contact form but I also was in the backoffice of my site and saw a Form creation tool package. Which one was the more "standard" way of doing a contact form and why?
Yes the form creation package you are seeing is 'Umbraco Forms' it is a really quick way to create forms to use in your Umbraco site; it is a paid for package (€99 for a domain licence) http://umbraco.com/products-and-support/forms/ but you can check it out for free if you install locally and run on localhost. It's definitely worth exploring what it can do; particularly if you want to avoid developing custom solutions all the time or have editors, who need to create forms quickly without developer assistance. It's possible to extend too; so when a form is posted you can integrate with other services easily etc,
However in some circumstances, depending on what you are trying to achieve with the posted data; it might be easier for you, particularly if you are a developer with MVC experience, to handle a form post with a surface controller; you then kind of arguably have more control over the html of the form and the handling of the data that is posted; but it's also arguable for something that is as simple as a contact form, just use Umbraco Forms,
Often it comes down to personal preference, and what you need to deliver for a particular project; rather than a standard way. Umbraco forms does so much for you, for very little outlay, but if you don't need that functionality, you are not forced to use it.
Thanks! Great explanation. As an MVC developer, I have no qualms about using the standard controller/view method. Although, I do have to learn a bit more about how this "SurfaceController" works. But it seems pretty straightfroward from the little I've seen thus far. I didn't realize that the umbraco forms were "pay-to-play" lol.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted