简体   繁体   中英

MVC3 .NET - How to add additional information when user enters personal details

I have a View/Screen that allows the user to enter their personal details. There are 2 sections (both contained in the same viewmodel):

  1. Your Name - consists of title, forename and surname fields
  2. Previous Names - consists of title, forename and surname fields

These are separate entities in the Database and the Model

However, a user could have more than 1 Previous Name and due to space constraints I thought about having an with image, pointing to another View that opens a new Tab in the web browser, rather than a new window as Javascript and/or popups could be disabled.

So, I am unsure if this is the correct approach as I don't see how I can get the additional previous names back to the parent view model.

Another idea (I've had whilst writing this question) is to make the image call a controller method that saves the additional name info to the viewmodel and then redisplay the view with the amended data in the viewmodel - I think this would work with javascript disabled - not very user friendly as the user would have to cycle through the Previous Names if they wanted to delete one of the records....

My ViewModel:

public User user { get; set; }
public List userPreviousNamesList;
public UserPreviousName userPreviousNames { get; set; }

Hmmmmm...... Any solutions/experience for such a scenario are most welcome.

For your first requirement, I believe it's about Binding Nested Models

Please follow this link Editing and binding nested lists with ASP.NET MVC 2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM