First Project

After installing extension, you can now create a new project. In New Project dialog select MVP Project for Web Forms. Write your project name and click Ok.

This will create a solution with 6 projects. Web, Presentation, DataAccess, Common, Business and DependencyResolver projects will be added to solution as well as required packages Bootstrap, Enterprise Library, JQuery, MVP.WebForms.Presenter, MVP.WebForms.View, Ninject and WebToolkit. At this point, solution is expected to be built without any errors. Otherwise, please check forums or contact with us.

After creation, basicly you are ready to go. You can just start developing your project and free to do whatever you want. If you want to use MVP Web Forms advantages, following steps will help you to understand how framework should be used.

First, you have to add a model interface to Common library. For our guide, we will try to create a project for car selling web site. Just add an interface which looks like this:

Now, we will add a presenter to presentation project. To do this, expand presentation project in solution explorer. Right click any of the items in the project.

Click Add Presenter menu item. Add presenter dialog will open. Select Listing from dropdown to add a presenter for listing purposes. This type of presenter will create a presenter for listing items in the View. Also you have to write name of the interface which we just added.

Doing so will add a presenter named CarListEditor.cs. This file has an interface to be implemented by View, and a concrete presenter class which will be used in view to trigger events in presenter.

At this step, you are supposed to create an interface called ICarBusiness to the Common layer. This interface should have a method with a name GetCarList. Method name may vary.

We will add a concrete class for ICarBusiness to the Business project. What will happen in this method is your implementation. You can either get list from data access layer or return results from business layer via a web service.

Now let's create our View. To do that, expand Web project. Right click any of the items. Click Create View menu item to open Create View dialog.

Select Listing from dropdown to add a view for listing purposes. Then, write name of the target common interface. At this guide, we will not use a master page. Select presenter type for this view. First check the apply presenter check box, then select CarListEditor from presenter list. Click next to create View.

Clicking next button will add an ASPX file and a code behind file for it. ASPX file is a simple scaffholded listing file which has basic styling of twitter bootstrap. Code behind file contains code generated for you. But some of the modifications must be done manually.

For this guide, we will simply list the cars we have. Cars property of the code behind class has bodies for get and set. Delete them, we don't need them for now. In the aspx file, find the table for car list. Place a for into the tbody element. In this for loop, add row element.

Now we go back to Business project. Here we have to add a Ninject module for CarBusiness. To do that, add a class which will have a name CarModule, to the Modules folder in Business project. CarModule class must be inherited from NinjectModule and implement load method. In Load method, we bind ICarBusiness interface to CarBusiness class. Result should look like this.

After adding CarModule, it has to be added to modules list of Business project. Open BusinessBootstrapper class in Business project. Add CarModule into the list in GetModules method.

Let's test what we got so far. In CarBusiness.GetCarList method, NotImplementedException is being thrown. Change that so that method will return an empty list of ICar. Then run project and open CarList.aspx page.

We have a running project and at this point tutorial ends. Database interaction, user interface design and memberships are subject to another tutorial.