Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7722573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:12:53+00:00 2026-06-01T04:12:53+00:00

Can someone explain to me why this doesn’t work? I’ve read lots of posts

  • 0

Can someone explain to me why this doesn’t work? I’ve read lots of posts about multiple submit buttons on one page, but I don’t understand what’s going on in the background. I’ve tried to follow what I see others doing in those posts, but none of it seems to work. I’m just trying to understand what is really going on here. I suspect it has something to do with what exactly happens when a page is posted.

Both buttons do a completely different thing. The first button posts the form. In the form’s post code, it is then redirected to Vehicle/Index. The second button does not post the form, and goes directly to /Vehicle/CreateNewVehiclePart.

Here is what I want. I want both buttons to submit the form (so I can perform validation and save the changes to the Vehicle before moving on). Once the Vehicle data is saved, I want to move to /Vehicle/AddPartsToVehicle or /Vehicle/CreateNewVehiclePart based upon which button is clicked.

<table class="layouttable">
    <tr>
        <td>
            @using (Html.BeginForm("AddPartsToVehicle", "Vehicle", FormMethod.Post, null))
            {
                <input type="submit" value="Add Parts To Vehicle" />
            }
        </td>
        <td>
            @using (Html.BeginForm("CreateNewVehiclePart", "Vehicle", FormMethod.Post, null))
            {
                <input type="submit" value="Create New Vehicle Part" />
            }
        </td>
    </tr>
</table>

Here is the Vehicle model:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Globalization;


namespace ShopLog.Models
{
    public class Vehicle
    {
    [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public Guid VehicleID { get; set; }

    [Timestamp]
    public Byte[] Timestamp { get; set; }

    [Required]
    [Display(Name = "Vehicle Name")]
    [MaxLength(30, ErrorMessage = "The {0} must be no more than {2} characters long.")]
    public string VehicleName { get; set; }

    [Display(Name = "Assigned To")]
    [MaxLength(30, ErrorMessage= "The {0} must be no more than {2} characters long.")]
    public string AssignedTo { get; set; }

    [Display(Name = "ID Number")]
    [MaxLength(30, ErrorMessage = "The {0} must be no more than {2} characters long.")]
    public string IDNumber { get; set; }

    [Display(Name = "Active")]
    public bool Active { get; set; }

    [Display(Name = "Sign Out Vehicle")]
    public bool SignOutVehicle { get; set; }

    [Display(Name = "Have Title")]
    public bool HaveTitle { get; set; }

    [Display(Name = "Mileage or Hours")]
    public int? MileageOrHours { get; set; }

    [Display(Name = "Make")]
    [MaxLength(30, ErrorMessage = "The {0} must be no more than {2} characters long.")]
    public string Make { get; set; }

    [Display(Name = "Model")]
    [MaxLength(30, ErrorMessage = "The {0} must be no more than {2} characters long.")]
    public string Model { get; set; }

    [Display(Name = "Year")]
    public int? Year { get; set; }

    [Display(Name = "Engine")]
    [MaxLength(30, ErrorMessage = "The {0} must be no more than {2} characters long.")]
    public string Engine { get; set; }

    [Display(Name = "Transmission Gears")]
    public int? TransmissionGears { get; set; }

    [Display(Name = "VIN")]
    [MaxLength(30, ErrorMessage = "The {0} must be no more than {2} characters long.")]
    public string VIN { get; set; }

    [Display(Name = "Serial Number")]
    [MaxLength(30, ErrorMessage = "The {0} must be no more than {2} characters long.")]
    public string SerialNumber { get; set; }

    [Display(Name = "Color")]
    [MaxLength(30, ErrorMessage = "The {0} must be no more than {2} characters long.")]
    public string Color { get; set; }

    [Display(Name = "Air Filter")]
    [MaxLength(30, ErrorMessage = "The {0} must be no more than {2} characters long.")]
    public string AirFilter { get; set; }

    [Display(Name = "Engine Oil Filter")]
    [MaxLength(30, ErrorMessage = "The {0} must be no more than {2} characters long.")]
    public string EngineOilFilter { get; set; }

    [Display(Name = "Fuel Filter")]
    [MaxLength(30, ErrorMessage = "The {0} must be no more than {2} characters long.")]
    public string FuelFilter { get; set; }

    [Display(Name = "Transmission Oil Filter")]
    [MaxLength(30, ErrorMessage = "The {0} must be no more than {2} characters long.")]
    public string TransmissionOilFilter { get; set; }

    [Display(Name = "HydraulicOilFilter")]
    [MaxLength(30, ErrorMessage = "The {0} must be no more than {2} characters long.")]
    public string HydraulicOilFilter { get; set; }

    [Display(Name = "Interior A/C Filter")]
    [MaxLength(30, ErrorMessage = "The {0} must be no more than {2} characters long.")]
    public string InteriorACFilter { get; set; }

    [Display(Name = "Differential Oil")]
    [MaxLength(30, ErrorMessage = "The {0} must be no more than {2} characters long.")]
    public string DifferentialOil { get; set; }

    [Display(Name = "Transmission Oil")]
    [MaxLength(30, ErrorMessage = "The {0} must be no more than {2} characters long.")]
    public string TransmissionOil { get; set; }

    [Display(Name = "Engine Oil")]
    [MaxLength(30, ErrorMessage = "The {0} must be no more than {2} characters long.")]
    public string EngineOil { get; set; }

    [Display(Name = "Tire Size")]
    [MaxLength(30, ErrorMessage = "The {0} must be no more than {2} characters long.")]
    public string TireSize { get; set; }

    [Display(Name = "Tire Pressure")]
    [MaxLength(30, ErrorMessage = "The {0} must be no more than {2} characters long.")]
    public string TirePressure { get; set; }

    [Display(Name = "Smog Due Date")]
    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:d}")]
    public DateTime? SmogDue { get; set; }

    [Display(Name = "Registration Due Date")]
    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:d}")]
    public DateTime? RegistrationDue { get; set; }

    [Display(Name = "Insurance Due Date")]
    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:d}")]
    public DateTime? InsuranceDue { get; set; }

    [Display(Name = "License Plate")]
    [MaxLength(30, ErrorMessage = "The {0} must be no more than {2} characters long.")]
    public string LicensePlate { get; set; }

    [Display(Name = "Owner")]
    [MaxLength(30, ErrorMessage = "The {0} must be no more than {2} characters long.")]
    public string Owner { get; set; }

    [Display(Name = "Previous Owner")]
    [MaxLength(30, ErrorMessage = "The {0} must be no more than {2} characters long.")]
    public string PreviousOwner { get; set; }

    [Display(Name = "Date Acquired")]
    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:d}")]
    public DateTime? DateAcquired { get; set; }

    [Display(Name = "Notes")]
    [DataType(DataType.MultilineText)]
    public string Notes { get; set; }

    [Required(ErrorMessage="Vehicle Type is required.")]
    public Guid VehicleTypeID { get; set; }
    public Guid? TransmissionTypeID { get; set; }

    //A vehicle can only have one VehicleType and one TransmissionType
    [Display(Name = "Vehicle Type")]
    public virtual VehicleType VehicleType { get; set; }

    [Display(Name = "Transmission Type")]
    public virtual TransmissionType TransmissionType { get; set; }


    //A vehicle can have many Parts
    [Display(Name = "Parts")]
    public virtual ICollection<Part> Parts { get; set; }

    //A vehicle can have many Warranties
    [Display(Name = "Warranties")]
    public virtual ICollection<Warranty> Warranties {get; set; }
}

}

Here is the Part model:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Globalization;

namespace ShopLog.Models
{
    public class Part
    {
    [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public Guid PartID { get; set; }

    public string Name { get; set; }
    public decimal Cost { get; set; }

    [DataType(DataType.MultilineText)]
    public string Notes { get; set; }

    //A Part can belong to many Vehicles
    public virtual ICollection<Vehicle> Vehicles { get; set; }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T04:12:55+00:00Added an answer on June 1, 2026 at 4:12 am

    I tried this in a simple project

    @model MvcApplication2.Models.LogOnModel
    
    @{
        ViewBag.Title = "Home Page";
    }
    
    @using (Html.BeginForm("About", "Home", FormMethod.Post, null))
    {
        <input type="submit" name="btn2" value="About" />
        @Html.TextAreaFor(m => m.UserName)
    }
    
    @using (Html.BeginForm("Index", "Home", FormMethod.Post, null))
    {        
        <input type="submit" name="btn1" value="Index" />
        @Html.TextAreaFor(m => m.UserName)
    }
    

    public class HomeController : Controller
    {
        [HttpPost]
        public ActionResult Index(LogOnModel a)
        {
            ViewBag.Message = "Welcome to ASP.NET MVC!";
    
    
            return View();
        }
    
        [HttpGet]
        public ActionResult Index()
        {
            return View();
        }
    
        [HttpPost]
        public ActionResult About(LogOnModel a)
        {
    
            return View();
        }
    }
    

    From what I can tell this works out of the box. I would check your routes…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone explain why this doesn't work? int main() { float* x; float a,
Can someone explain why this code doesn't work as expected? I would expect it
Can someone explain me why this doesn't work: $(function() { var damg = $(.hidden).val();
Can someone explain why this doesn't work like I think it should. double[] numbers1
I am newbie to jQuery, can someone explain what this code does: $(#currency form).submit(function(e)
Can someone explain me why this code give me back always only one bluetooth
Can someone explain this result to me. The first test succeeds but the second
Can someone explain this to me. I am pretty good with perl regular expressions
Can someone explain this to me? In particular the difference between: http://github.com/whymirror/greg and http://piumarta.com/software/peg/
Can someone explain what this means? int (*data[2])[2];

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.