We are starting a new ASP.NET MVC project and we would like to establish a pattern of development that will allow flexibility in the UI. The general idea is that we would like to develop a set of related controls as a unit (i.e. a set of inputs and a submit button) and maintain the flexibility to decide later 1 of 3 UI options
- Have that set of controls with its submit button be alone on a web page, OR
- Have the set of controls be together with other sets of controls on the same page, and each set has its own submit button, OR
- Have the set of controls be together with other sets of controls on the same page, but there is only one submit button for the whole page
Is there any pattern or strategy of development that wou开发者_JAVA技巧ld allow us to develop with this flexibility?
- I would create a Partial view for this scenario. Just lay out the form in your Partial view and drop it into whichever view you see fit.
- Since the entire body is not wrapped in a form tag like WebForms, there is no limit to the number of forms you can use on a page as long as they're not nested.
- This one is a bit tougher. Unlike WebForms where you could put controls all over the page and have a button click collect those you can't do that with MVC. Your options would be to make sure the inputs are within a form or use JavaScript to collect all the values and submit those.
精彩评论