I'm currently working on an application which is being developed using C# and Asp.Net MVC. I have a form which is split into two parts. There are 3 submit buttons each if clicked, of course performs a client side validation and complains if one or more of the inputs are required.
The clicks of as follows:
- Submit - validation should not be first half of the form
- Save - no validation required
- Temporarily Add - validation on the bottom half of the form
My view model class looks something like
public class ViewModel
{
public User User { get; set; } //used for first half of the form
public Department Department { get; set; } //used for second half of the form
}
and my POCO classes look like
public class User
{
public int Id { get; set; }
[Required]
public string Username { get; set; }
public DateTime Dob { get; set; }
//more required properties
}
public class Department
{
public int Id { get; set; }
[Required]
public string DepartmentName { get; set; }
//more required properties
}
On Save click if I had class cancel
then that seems to work and no validation is done. However I can seem to figure out how I can do it for the other two buttons. Is there a way or am I completely going off the rail here.