Hi,
I need to know about MVC pattern.Is it the same what vs.net generates by default whenever we create a asp.net web application(generates a .aspx page and an .aspx.cs thus seperating model and view).
If it is different , can somebody please let me know what exatly should be where.i read many article on MVC but didn't got any working sample to understand.
Also need to know in what cases whould we use MVC pattern, as these days everbody talkes about that his application is based on MVC.
Java has many MVC framewokrs.Do .net also have any such
regards

MVC when to use,MVC framework
barkingdog
Hi Thompson.
Unfortunately, I have not been able to find a simple answer for this.
Start by reading this
http://msdn.microsoft.com/library/default.asp url=/library/en-us/dnpatterns/html/DesMVC.asp
Then read about UIP application block
http://msdn.microsoft.com/library/default.asp url=/library/en-us/dnpag/html/uipab.asp
and then about CAB (Composite UI Application Block) http://www.gotdotnet.com/codegallery/codegallery.aspx id=22f72167-af95-44ce-a6ca-f2eafbf2653c
Possibly also read about MVP pattern http://msdn.microsoft.com/msdnmag/issues/06/08/DesignPatterns/default.aspx
And dont miss atlas.net if you want Ajax capabibilities as well.
Also read about asp.net web parts.
In my opinion UIP+Atlas.net+Asp.Net web parts - used together - helps you achieve all the objectives.
Pranshu
nef001
Hi All,
a good enough explanation about MVC pattern is available in "Starting with Model/View/Controller (MVC) Architecture Pattern" at http://www.skyscrapr.net/blogs/solution/archive/2006/08/07/262.aspx (the host, SkyScrapr, is a site for aspiring architects)
At the end, it suggests an excellent webcast telling how MVC is achievable from the basic Windows Forms generated as output by Visual Studio wizards
Hope it helps
aharuray
Hi Pranshu,
Thanks a lot for a lot of information. i will go through all these links one by one and will get back to you.
meanwhile can you please let me know what pattern is exactly followed by .net when it creates a .aspx file and corresponding .aspx.cs file.
Also how can we use this structure in avoiding redundant code.
regards
JLesch
Hi,
I am afraid, i dont know the name of a pattern for code behind. It is definitely not MVC though.
It lets you handle events and pass data back and forth between business logic / data layer to the view. This could implement the busines logic itself. The code behind may also manipulate view by accessing and manipulating the controls.
Though - its lot better than the ASP pages where you had to do all the event wiring within.
There are third party MVC implementations like Monorail, maverick etc. but I am not sure about how popular these are and whether these are out of Beta.
The above links ( for MVP and MVC) tell you how to implement the same without using a different framework - by structuring your code such.
Essentially, the aspx/ascx will become the view, the code behind will become the controller ( handling events) and the model will be objects which know how to fetch the data within them.
The view also supports templatization ( like Tiles / Struts if comparing with Java world) using asp.net web parts and using master pages.
Regards
Pranshu
Olaf vd Sanden
Model, View, Controller pattern is not the same as the code behind in visual studio.
MVC splits the user interface into 3 parts. The Model is the business entity, the View is the user interface and the Controller defines how the two interact and how each should update after the other changes.
For example, the user interface asks the Controller to alter property x. The controller tells the model to change property x. The model then instructs the view (through the controller), that the change could not accur because the value was invalid.
This has many advantages including making it easier to automate testing as visual elements are difficult to test.
Model
The object model. For example, in a stock control application, the 'Add Product' window will allow the user to create Product Objects. The model and object are synonomous here.
View
The design of the user interface (Forms, Controls etc). This is the Form you define in the visual designer in Visual Studio.
Controller
This defines how the View and the Model intereact. Normally, the user interface will inform the controller what action the user wants to perform, and the controller tells the model to do something. The Controller then informs the View how to update itself.
Sometimes, the View will subscribe to events on the model to allow it to decide how to update itself. This is not a perfect implementation of MVC but is pragmatic.
However, I have worked with object models that don't define enough events for changes it makes. Then the Controller is required to tell the Interface how to update itself.
This is a very simplified description but I hope this gives you a better idea.