[RESOLVED]Submit button posting to different action

How do i post the submit button to a different action?

    ViewBag.Title = "VehicleManagement";


    <h4>Vehicle Management System</h4>
    <hr />
    <form action="Vehicle/VehicleManagement" method="post">
        <input type="submit" value="Add Vehicle" onclick="location.href='@Url.Action("CreateVehicle","Vehicle")'"/>
 public class VehicleController : Controller
        // GET: Vehicle
        public ViewResult VehicleManagement()
            return View("VehicleManagement");

        public PartialViewResult CreateVehicle()
            return PartialView("VehicleEntry");

Alternatively, you can use jquery as below

<button id="btnSubmit">Add Vehicle</button>
 $(‘#btnSubmit’).on(‘click’, function (e) {
            window.location.href = "@(Url.Action("CreateVehicle", "Vehicle"))";

Leave a Reply