After years of Web Forms development I've decided to give MVC a go. I've been able to work through most of the other stumbling blocks, but I'm kind of stuck on this one.
In Web Forms I would create controls for each of my forms in order to modularize so I could re-use them throughout my sites. I am attempting to do the same thing in MVC but with partial views and am not having much luck. It's probably something simple, and maybe I'm just not searching on the right set of keywords to find the obvious example.
Lets say I create a strongly typed partial view for a Login form. I want to include it on several pages of my site. Since the code is separate from the view, how do I encapsulate the logic so it can be easily reused in several views? In Web Forms, I just stuck it in the code-behind. In MVC do I have to put the code in every view controller where I want to use the control?
Second, how do you handle posts from partial views? I've tried creating strongly typed views and partial views, but the view models don't seem to populate automagically like they do when the form is directly on the view. I could always use the FormCollection as the action parameter and just force the values into my partial view models, but that doesn't seem too elegant. Can someone point me to some functional examples of how to use multiple strongly typed partial pages with forms on a single view (e.g. A login page with a login control and a register control)