I'm using MVC3 Razor. I have 2 submit buttons setup on my view but the problem I'm having is that both submit buttons cause the validation of the model. I want to hook up individual submit buttons with specific input controls for validation.
Asp.net mvc3 razor with multiple submit buttons
asp.netasp.net-mvc-3validation
Related Topic
- How to use ternary operator in razor (specifically on HTML attributes)
- Asp.net-mvc – Replace line break characters with
in ASP.NET MVC Razor view - C# – MVC3 Razor DropDownListFor Enums
- ASP.NET MVC3 – textarea with @Html.EditorFor
- Css – @media media query and ASP.NET MVC razor syntax clash
- Html – How to force a html5 form validation without submitting it via jQuery
- Html – An invalid form control with name=” is not focusable
Best Answer
I know this is a few months old but the solutions here seemed needlessly complex and there's no accepted answer yet. If you name your inputs the same but give them different values, you can get that value in your controller just by including a string with the name of the input as a variable. This is how I solved this problem:
View:
Controller: