Jean Paul's Blog

There are 2 types of People in the World, One who Likes SharePoint and..

  • Microsoft MVP

  • MindCracker MVP

  • CodeProject MVP

  • eBook on SharePoint 2010

  • eBook on Design Patterns

  • eBook on Windows Azure

  • NLayers Framework @ CodePlex

  • MSDN Forums

  • .Net vs. Java

    Due to Public Demand
  • Advertisements

Part 4: WCSF : Adapting to Model View Presenter (MVP) architecture

Posted by Paul on November 9, 2010

One of the cool benefits of WCSF is the support of Model View Presenter (MVP). 

The advantages of MVP are many:

  • Isolation of User Interface management code through Presenter
  • Isolation of Business Logic code through Controller
  • Improved Unit Test support for code

Note: The MVP here also contains a Controller class

Learn by Example

From the previous part, we can try to create a web page having one textbox and button.

On clicking the button the data will be saved to session.  Let us see what are the infrastructure needed for that.

Step 1: Create new Page

Right click on our previous WCSF project and use the context menu “Web Client Factory”> Add Page with Presenter


The following wizard will appear:


Enter the view name as “MyData” and click Finish.

Right click on the MyData.aspx and make it Default page.

Step 2: Add Data property to IDefaultView

Open the IMyDataView.cs from Shell project and add the following property inside it.


As the MVP provides decoupling of user controls from code, we need to create properties for each user interface element.

This could be like Name, Address, HasLicense etc. for user controls like TextBox, RadioButton etc.

For DataGridView we will need to declare properties like IList<Employee> etc.

Step 3: Implement the Data property

Now we need to implement the new Data property inside our aspx page.

First we have to create a textbox in the webpage and connect it to the Data property.

For this place a new textbox and name it txtData.  Place a button too aside.


Create the property named Data inside the MyData.aspx page like following.


Step 4: Build the solution

If the build succeeds we are in good position.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s