Currently I have one page to my umbraco site with one Document type called 'HomePage'
I have added a custom controller which returns my home page veiw, that works fine.
From that same view I am trying to post the data from a form, I have created an action in the same controller to to handle the post called 'Contact'
I have given it the attibuite [HttpPost] but when I submit the form I am not able to hit that controller I just get 'Page not Found', this is my code:
public class HomePageController : RenderMvcController { public override ActionResult Index(RenderModel model) { return View("HomePage"); } [HttpPost] public ActionResult Contact(FormCollection c) { //I WANT TO PROCESS MY FORM DATA HERE }
Which talks about haddling a form post, but it involes making a new document type to represent the form, and it gos on... but what I want to know is......... Is it really necessary to do this? Surely there must be a simple way just to post the back to the controller that renders it..?
Are you in a view or partial View. I create a property on your model for nodeid and then post it as a hidden field with your form. (this will save problems)
Is there any reason why you have a defauly ActionResult Index? If not remove it its adding complication.
public class HomePageSurfaceController : SurfaceController
{
[AcceptVerbs("POST")]
[HttpPost]
public ActionResult Contact(FormCollection collection) {
//DO SOME WORK HERE //I WANT TO PROCESS MY FORM DATA HERE }
How to handle form post Umbraco 6 - MVC
Currently I have one page to my umbraco site with one Document type called 'HomePage'
I have added a custom controller which returns my home page veiw, that works fine.
From that same view I am trying to post the data from a form, I have created an action in the same controller to to handle the post called 'Contact'
I have given it the attibuite [HttpPost] but when I submit the form I am not able to hit that controller I just get 'Page not Found', this is my code:
public class HomePageController : RenderMvcController
{
public override ActionResult Index(RenderModel model)
{
return View("HomePage");
}
[HttpPost]
public ActionResult Contact(FormCollection c)
{
//I WANT TO PROCESS MY FORM DATA HERE
}
<form id="contact-form" action="HomePage/Contact" method="post">
<input id="name" class="rounded" name="contact[name]" type="text" />
<input id="email" class="rounded" name="contact[email]" type="text" />
<input id="submit-mail" class="submit-btn rounded" type="submit" value="SEND MESSAGE" />
</form>
I found this post: http://www.systenics.com/blog/creating-an-ajax-enabled-contact-form-in-umbraco-6-with-aspnet-mvc-4-and-twitter-bootstrap/?tag=Umbraco+6
Which talks about haddling a form post, but it involes making a new document type to represent the form, and it gos on... but what I want to know is......... Is it really necessary to do this? Surely there must be a simple way just to post the back to the controller that renders it..?
Any ideas?
No replies :-(
hi i can help :)
hi i can help :) Take a look at this too start with :). http://our.umbraco.org/documentation/Reference/Mvc/surface-controllers
Are you in a view or partial View. I create a property on your model for nodeid and then post it as a hidden field with your form. (this will save problems)
Is there any reason why you have a defauly ActionResult Index? If not remove it its adding complication.
public class HomePageSurfaceController : SurfaceController
{
[AcceptVerbs("POST")]
[HttpPost]
public ActionResult Contact(FormCollection collection)
{
//DO SOME WORK HERE
//I WANT TO PROCESS MY FORM DATA HERE
}
}
The for the form post
@Html.BeginForm("Contact","HomePageSurface", additional parameters)
{
}
Hope this helps. Any other questions please ask :)
is working on a reply...