Monday 2 March 2009

Model View Controller MVC in ASP.NET 2.0

Model View Controller MVC is a design pattern that is practiced in asp.net particularly to separate Data Access layer,Business Logic layer and presenatation layer.In MVC , Model is data ,Data access classes, Controller is business logic classes and View is classes,control, pages that represent data to view in differnt ways.It is Controller who pass and get data netween View and Model.

In Viiusual Studio 2008, Microsoft has implemented MVC pattern.There is MVC templates in Viusal studio 2008 with .NET 3.5.However There is no way to implement thsese tempales in ASP.net 2.0 and visual studio 2005.To Implement MVC in .Net 2.0 and Visual studio 2005, we need to create our own classes.
The Logic is pretty simple.
  • Create classes that implement data access code.(e.g inserting,updating,deleting data using ado.net classes).That will be our Model
  • Create classes that acts as middle layer between presentation layer and Model.(e.g sending and receing reselts between data Access classes and asp.net aspx page) thta will be our Controller.
  • Create Page,user Control(.ascx),Datalist controls that display data.That will be our View.

No comments:

Post a Comment