I am trying to create a View in ASP.NET MVC in which different parts of a view model are modified separately to capture intent.
For example, the modification on users can be done in one of the following ways at a time:
- Modify Name,
- Modify Email,
- Modify Password,
- Modify Status
public class UserEditViewModel
{
public string DepartmentDetails { get; set; }
[HiddenInput(DisplayValue = false)]
public Guid UserId { get; set; }
public class UserNameEditModel
{
[Required(ErrorMessage = "Name Required")]
[DisplayName("Name")]
[StringLength(50, ErrorMessage = "Name must be less than or equal to 50 characters")]
public string Name { get; set; }
}
public class UserPasswordEditViewModel
{
[Required(ErrorMessage = "Password cannot be Empty")]
[DisplayName("Password")]
public string Password { get; set; }
[Required(ErrorMessage = "Confirm Password is Required")]
[DisplayName("Confirm Password")]
public string ConfirmPassword { get; set; }
}
public class UserStatusEditViewModel
{
[Required(ErrorMessage = "Status Required")]
[DisplayName("Status")]
public bool Status { get; set; }
[Required(ErrorMessage = "Comment Required")]
[DisplayName("Comment")]
public string Comment { get; set; }
}
}
What I want to do its create strongly typed partial views based on outerclass+ one of inner classes. Each partial view will have its own form submission which will have action pointed out to a separate controller action (edit password, editname, editstatus...)
I tried t0 create view based on outerclass+ one of inner classes, which is something I got in the automated view builder wizard but it was unable to resolve DepartmentDetails as well as UserID of outerclass.
- Is what I am wanting to do possible in ASP.NET MVC 2 / 3 Beta?
- I will use Ajax later on for enhancement but I would like to do as much form post without it.
- If it is possible to have separate forms on partial view work independently then I guess one solution might be to have User Id and Details on each of the EditviewModel and and have view use one single ViewModel.