Background

ASP.NET MVP pattern evolved during the late 90s. It is the descendent of MVC pattern with a slight change in the design pattern, i.e., it implements the observer design approach of MVC. The rest of the components remain the same which means the model and view do their task as in MVC.

MVP (Model-View-Presenter)

ASP.NET MVP consists of three parts. They are:

Model

View

Presenter

Model

Model is the domain type or the business level object. It contains the application data and provides logics and behaviours to access the data. Model needs to be independent and shouldn’t have any problems and issues regarding the user interface (UI). Since the model should be independent, the same model can be used by different type of UI level applications.

View

A view is a place holder which holds the model data and shows them to the application users. Simply, view is a web form for presenting the model data. Model doesn’t have direct link with views while view should have knowledge about their models.

Presenter

Presenter addresses the user input and uses it to manipulate the model data. A view passes the user input actions to the presenter for interpretation. Presenter will act upon the received data from the view and communicate with model and returns result to the view.The following figure describes the basic flow of MVP pattern.

Fig. MVP architecture

MVP Vs. Web Forms Vs. MVC

Web forms have high productivity and less control over markup, URL and code. MVC (Model View Controller) has high control on markup, URL and code and less productivity. Here comes the MVP which balances between the productivity and control.

Choosing Between MVC and MVP

In MVC, the model stores the data, view is the representation of that data and the controller allows the user to change the data. When the data is changed, all the views are notified of the change and they put themselves as necessary. MVP is a derivative of MVC.

MVP gives less control to the view and puts most of the responsibility in the presenter. It is an attempt to make all logic part of the presenter, thus the view is “passive”. The basic idea of the MVC and MVP is the same, the model stores the data, the view is representation of that data and the presenter coordinates the data.

Entity Framework Introduction

In the real world programming, the database developers prefer to use relational model to represent data while the application developers prefer to use object oriented models. This difference in two models is addressed by ADO.NET Entity Framework. The ADO.NET Entity Framework is a descendent of ADO.NET to provide object relational mapping between conceptual entities which are .NET classes and the data store. Entity framework uses entity data model which consists of storage schema, the conceptual schema, the mapping schema and the entity classes.

Process Flow

At first, create a new ASP.NET empty web application in a VWD (Visual Web Developer). In my case, I have used VS 2010.

After that, add a new interface for view names IView in file IView.cs. The code looks like this:

Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

It shouldn't be misunderstood that this article was for beginner level and it was just intended for giving introduction about the emerging technologies. In my coming article I am planning to give a detailed description regarding Entity Framework.