Can someone help me understanding Model-View-Controller method to be implemented on WebForms? I am confused on couple of things:
-
If we have ABC.ASPX and ABC.CS files, what is view? is it only ABC.ASPX file? or combination of .ASPX + .CS file?
-
do we consider ABC.CS file as controller? If no, will it be a seperate class for controller?
-
Does database connection and data retreival go into Model or a seperate class which will be called by Model?
Can someone give a simple example for implementing Model-View-Controller in webforms?
Update
Hi guys, my question is how to implement Model-View-Controller methodology using WebForms not about ASP.NET MVC2.0. I apologise for the confusion.
Cheers
As others have posted there is a lot of information out there on MVC, so I’ll answer your question…
It is both…however the .cs file is referenced as code behind but both make up the view.
No, a separate class would be the controller.
You could go either way. you could place this logic in the model, however you could also functionalize it out into services, which can then be called as needed by the model. IMHO the second route is the way to go, as I don’t want to make my model dependent on external entities and it also makes testing the model easier, as you can separate out the services testing from the model testing.
Diagram can be seen here, which has some great imagery as reference points.