Can I add more than one form in a single view , how to work with it. Can this be done using only one model or do I need to use different models for different forms. Can any one explain me with a good example or suggest me a good article which is explaining in detail.
相关问题
- MVC-Routing,Why i can not ignore defaults,The matc
- parameters in routing do not work MVC 3
- There is no ViewData item with the key 'taskTy
- TextBoxFor decimal
- Install ASP.NET 5.0 version of System.ServiceModel
相关文章
- MVC CDN fallback for Style Bundle
- Add to htmlAttributes for custom ActionLink helper
- How to get a list of connected clients on SignalR
- How do you redirect to the calling page in ASP.NET
- Change color of bars depending on value in Highcha
- The program '[4432] iisexpress.exe' has ex
- ASP.Net MVC 4 Bundles
- How to get server path of physical path ?
Lars's answer is a good solution. I would even go with something like this:
This way you only extend your basic model class and save a couple of lines of code.
You should probably use two models and use partial view for each. Otherwise when you post the form you will need to take into consideration that one form may not have been filled out and model may be missing data.
This is a good question, I had problems with this myself when I was a newbie in mvc.
I think a good example here is the registration form and login form on the same page.
A keyword is ViewModel, which is essential to solve this.
In your Model class:
In you Controller:
In your View I've used 1 main View, and 2 Partial Views to split it up:
Main View:
Partial View _LoginForm:
Partial View _RegisterForm:
Please ask if any of the code is unclear for you.