I am using ASP.net MVC 4 with the Razor engine.
I have a page (Index.cshtml) and a controller (HomeController.cs)
I am trying to connect my submit button to the result of an action in my controller, but I cannot get it to light up.
My HTML:
@using (Html.BeginForm("SubmitForm", "Home", FormMethod.Post)) { <div class="main-Background"> ******lots of other html here******* <button type="submit" id="btnSave">Save</button> </div> }
My controller:
public class HomeController : Controller { public ActionResult Index() { ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application."; return View(); } public ActionResult About() { ViewBag.Message = "Your app description page."; return View(); } public ActionResult Contact() { ViewBag.Message = "Your contact page."; return View(); } [HttpPost] public ActionResult SubmitForm() { return View(); } }
At the moment, I have not implemented a model for passing values to the controller, I just wanted to see if I can run ActionResult SubmitForm.
I tried @using (Html.BeginForm()) without parameters, I also tried to include [HttpPost] over my ActionResult, with no luck.
Edit I also tried using <input type="submit" id="btnSave">Save</input> instead of a button.
I don't know where I'm wrong
source share