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
I am trying to create a surface controller using this video but for some reason it won't handle my posts. this is my controller code:
public class ContactFormController : SurfaceController { // // GET: /ContactForm/
public ActionResult Index() { return PartialView("ContactForm", new ContactFormViewModel()); } [HttpPost] public ActionResult FormSubmit(ContactFormViewModel model) { return RedirectToCurrentUmbracoPage(); } }
this is my cshtml code:
@using (Html.BeginUmbracoForm<SurfaceControllersSample.Controllers.ContactFormController>("FormSubmit")) { <div> @Html.TextBoxFor(m => m.Name, new { placeholder = "Name" }) </div> <div> @Html.TextBoxFor(m => m.Email, new { placeholder = "Email" }) </div> <div> @Html.TextAreaFor(m => m.Message, new { placeholder = "Message" }) </div> <div> <button id="submit">Send</button> </div> }
it will go to the "Index" method but not the "FormSumbit" Method. Any ideas?
Hi Moran,
I believe you should change your class name from ContactFormController to ContactFormSurfaceController and also in your cshtml file
ContactFormController
ContactFormSurfaceController
@using (Html.BeginUmbracoForm<SurfaceControllersSample.Controllers.ContactFormSurfaceController>("FormSubmit"))
hope that helps.
Cheers
Ali
Hi Thanks, I named it something else and forgot to attach the code for the most important thing, my controller :) here it is:
public class ContactFormController : SurfaceController { // // GET: /ContactForm/ public ActionResult Index() { return PartialView("ContactForm", new ContactFormViewModel()); } [HttpPost] public ActionResult FormSubmit(ContactFormViewModel model) { return RedirectToCurrentUmbracoPage(); } }
Even if I tried to insert a breaking point in the FormSubmit, But it won't get there.
Any thoughts?
Seems good :) but make sure you are running in MVC mode and the template you are outputting the form on is a razor view and not a .net masterpage
And make sure you don't have nested forms...
The controller's name must be suffixed with the term 'SurfaceController' based on this page:
@Ali Don't think that's mandatory...
Ok So I just need to rename my 'ContactFormController' to 'ContactFormSurfaceController'? I did that and updated my code accordingly but still no post :( this is my code in the master page maybe I need to call the FormSumbit method also
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @{ Layout = "Master.cshtml"; } <h1>@CurrentPage.Name</h1> @Html.Action("Index", "ContactFormSurface")
Thanks Tim My bad I had a form tag in the master page, old habits die hard :) Thanks everyone :)
P.S Great work with the videos Tim :)
@Moran thanks :) and glad I could help
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
handle post in surface controller
I am trying to create a surface controller using this video but for some reason it won't handle my posts. this is my controller code:
public class ContactFormController : SurfaceController { // // GET: /ContactForm/
this is my cshtml code:
it will go to the "Index" method but not the "FormSumbit" Method. Any ideas?
Hi Moran,
I believe you should change your class name from
ContactFormController
toContactFormSurfaceController
and also in your cshtml filehope that helps.
Cheers
Ali
Hi Thanks, I named it something else and forgot to attach the code for the most important thing, my controller :) here it is:
Even if I tried to insert a breaking point in the FormSubmit, But it won't get there.
Any thoughts?
Seems good :) but make sure you are running in MVC mode and the template you are outputting the form on is a razor view and not a .net masterpage
And make sure you don't have nested forms...
Hi Moran,
The controller's name must be suffixed with the term 'SurfaceController' based on this page:
@Ali Don't think that's mandatory...
Ok So I just need to rename my 'ContactFormController' to 'ContactFormSurfaceController'? I did that and updated my code accordingly but still no post :( this is my code in the master page maybe I need to call the FormSumbit method also
Thanks Tim My bad I had a form tag in the master page, old habits die hard :) Thanks everyone :)
P.S Great work with the videos Tim :)
@Moran thanks :) and glad I could help
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.