﻿<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Philip Beadle's Blog</title>
    <description>This blog is more general than my Blog at http://www.dotnetnuke.com/Community/Blogs/tabid/825/Default.aspx.  You'll find mostly technical tips and tricks and things i am doing in the MS user group community.</description>
    <link>http://philipbeadle.net/Home/tabid/252/BlogId/3/Default.aspx</link>
    <language>en-US</language>
    <webMaster>philip.beadle@live.com.au</webMaster>
    <pubDate>Thu, 29 Jul 2010 23:37:46 GMT</pubDate>
    <lastBuildDate>Thu, 29 Jul 2010 23:37:46 GMT</lastBuildDate>
    <docs>http://backend.userland.com/rss</docs>
    <generator>Blog RSS Generator Version 3.5.1.19887</generator>
    <item>
      <title>My new book – Silverlight for Dummies ready to buy</title>
      <description>&lt;p&gt;Quick note to spruik my new book &lt;a href="http://www.dummies.com/store/product/Microsoft-Silverlight-4-For-Dummies.productCd-0470524650.html"&gt;Silverlight For Dummies&lt;/a&gt;, you can buy it all over the net and at good book stores.&lt;/p&gt;</description>
      <link>http://philipbeadle.net/Home/tabid/252/EntryId/627/My-new-book-ndash-Silverlight-for-Dummies-ready-to-buy.aspx</link>
      <comments>http://philipbeadle.net/Home/tabid/252/EntryId/627/My-new-book-ndash-Silverlight-for-Dummies-ready-to-buy.aspx#Comments</comments>
      <guid isPermaLink="true">http://philipbeadle.net/Home/tabid/252/EntryId/627/My-new-book-ndash-Silverlight-for-Dummies-ready-to-buy.aspx</guid>
      <pubDate>Thu, 06 May 2010 20:46:01 GMT</pubDate>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://philipbeadle.net/DesktopModules/Blog/Trackback.aspx?id=627</trackback:ping>
    </item>
    <item>
      <title>Step by Step Webforms MVP and DotNetNuke – Part 2.</title>
      <description>&lt;p&gt;In Part 1 I set up the standard Starter Kit module to use interfaces and be more testable.  In Part 2 I will implement the MVP Pattern using the Web Forms MVP project that is now included as part of DotNetNuke.  The following code samples assume you are using DNN 5.4.  There are a few changes from DNN 5.3 that make it easier to write tests and get around an issue with Windsor Castle’s problems with classes that implement more than one interface.&lt;/p&gt;  &lt;p&gt;In Part 1 I listed the classes and interfaces we will need.  The M part of MVP is for Model so the first class to add will be the model for the module.  The model will store any properties you need such as whether the item is editable, the lsit of items and any other properties you will need to store for use in the presenter.  In this way its a little like the View-Model used in MVVM.&lt;/p&gt;  &lt;p&gt;Follow these steps to add the models for the Edit and View aspects of your module:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Right click the Models folder and select Add Class. &lt;/li&gt;    &lt;li&gt;Name the first class ViewWebformsMVPModel. &lt;/li&gt;    &lt;li&gt;Add the name space to the class. &lt;/li&gt;    &lt;li&gt;Add a property to handle whether or not the Item in the list is editable by adding the following code      &lt;br /&gt;      &lt;div class="csharpcode"&gt;       &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Private&lt;/span&gt; _IsEditable &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Boolean&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Property&lt;/span&gt; IsEditable() &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Boolean&lt;/span&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;            &lt;span class="kwrd"&gt;Get&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;                &lt;span class="kwrd"&gt;Return&lt;/span&gt; _IsEditable&lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;            &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Get&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;            &lt;span class="kwrd"&gt;Set&lt;/span&gt;(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; value &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Boolean&lt;/span&gt;)&lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;                _IsEditable = value&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;            &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Set&lt;/span&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Property&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;
    &lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/li&gt;

  &lt;li&gt;Add another property to hold a List of the items 
    &lt;br /&gt;

    &lt;div class="csharpcode"&gt;
      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Private&lt;/span&gt; _ListWebformsMVPInfo &lt;span class="kwrd"&gt;As&lt;/span&gt; List(Of WebformsMVPInfo)&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Property&lt;/span&gt; ListWebformsMVPInfo() &lt;span class="kwrd"&gt;As&lt;/span&gt; List(Of WebformsMVPInfo)&lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;            &lt;span class="kwrd"&gt;Get&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;                &lt;span class="kwrd"&gt;Return&lt;/span&gt; _ListWebformsMVPInfo&lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;            &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Get&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;            &lt;span class="kwrd"&gt;Set&lt;/span&gt;(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; value &lt;span class="kwrd"&gt;As&lt;/span&gt; List(Of WebformsMVPInfo))&lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;                _ListWebformsMVPInfo = value&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;            &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Set&lt;/span&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Property&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;
    &lt;style type="text/css"&gt;



.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/li&gt;

  &lt;li&gt;Add another class and call it EditWebformsMVPModel &lt;/li&gt;

  &lt;li&gt;Add a property to hold the item you are editing by adding the following code: 
    &lt;br /&gt;

    &lt;div class="csharpcode"&gt;
      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Private&lt;/span&gt; _Item &lt;span class="kwrd"&gt;As&lt;/span&gt; WebformsMVPInfo&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Property&lt;/span&gt; Item() &lt;span class="kwrd"&gt;As&lt;/span&gt; WebformsMVPInfo&lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;            &lt;span class="kwrd"&gt;Get&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;                &lt;span class="kwrd"&gt;Return&lt;/span&gt; _Item&lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;            &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Get&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;            &lt;span class="kwrd"&gt;Set&lt;/span&gt;(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; value &lt;span class="kwrd"&gt;As&lt;/span&gt; WebformsMVPInfo)&lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;                _Item = value&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;            &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Set&lt;/span&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Property&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;
    &lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Thats the models done now the next letter in MVP is for View so I’ll now show you how to set up the views for the Edit and View screens.  The view will have an interface that defines the events and any methods that are needed.  The Interface for ViewWebFormsMVP is the simplest kind as it has no events or methods.  The Interface for the edit screen will have events for the three buttons on it for Save, Cancel and Delete and also two methods to control the visibility of the Delete button and the audit control.  To get the ascx controls to use the new interface you just implement in the code behind.  Doing this allows you to test the model and presenter with a mock view.&lt;/p&gt;

&lt;p&gt;Follow these steps to set up the Views:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Drag the edit and view ascx files into the Views folder. &lt;/li&gt;

  &lt;li&gt;Right click the Views folder and add two interfaces, one called IViewWebformsMVP and the other called IEditWebformsMVP. &lt;/li&gt;

  &lt;li&gt;Add the following bolded code to the IViewWebformsMVP interface so that view knows how to find the model: 
    &lt;div class="csharpcode"&gt;
      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;Imports&lt;/span&gt; DotNetNuke.Web.Mvp&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt; &lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&lt;span class="kwrd"&gt;Namespace&lt;/span&gt; YourCompany.Modules.WebFormsMVP&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Interface&lt;/span&gt; IViewViewWebformsMVP&lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;        &lt;strong&gt;&lt;span class="kwrd"&gt;Inherits&lt;/span&gt; IModuleView(Of ViewWebformsMVPModel)&lt;/strong&gt;&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Interface&lt;/span&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt; &lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;&lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Namespace&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;
    &lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/li&gt;

  &lt;li&gt;Add the following bolded code to IEditWebformsMVP 
    &lt;br /&gt;

    &lt;div class="csharpcode"&gt;
      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;Imports&lt;/span&gt; DotNetNuke.Web.Mvp&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt; &lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&lt;span class="kwrd"&gt;Namespace&lt;/span&gt; YourCompany.Modules.WebFormsMVP&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt; &lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;    &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Interface&lt;/span&gt; IEditWebFormsMVP&lt;/pre&gt;

      &lt;pre&gt;&lt;strong&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Inherits&lt;/span&gt; IModuleView(Of EditWebformsMVPModel)&lt;/strong&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;strong&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Sub&lt;/span&gt; ShowAuditControl(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; show &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Boolean&lt;/span&gt;)&lt;/strong&gt;&lt;/pre&gt;

      &lt;pre&gt;&lt;strong&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Sub&lt;/span&gt; ShowDeleteButton(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; show &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Boolean&lt;/span&gt;)&lt;/strong&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;strong&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt; &lt;/strong&gt;&lt;/pre&gt;

      &lt;pre&gt;&lt;strong&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Event&lt;/span&gt; Cancel &lt;span class="kwrd"&gt;As&lt;/span&gt; EventHandler&lt;/strong&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;strong&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Event&lt;/span&gt; Delete &lt;span class="kwrd"&gt;As&lt;/span&gt; EventHandler&lt;/strong&gt;&lt;/pre&gt;

      &lt;pre&gt;&lt;strong&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Event&lt;/span&gt; Save &lt;span class="kwrd"&gt;As&lt;/span&gt; EventHandler(Of UIEventArgs(Of WebformsMVPInfo))&lt;/strong&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt; &lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Interface&lt;/span&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt; &lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;&lt;span class="kwrd"&gt;End&lt;/span&gt; Namespace&lt;/pre&gt;
    &lt;/div&gt;
    &lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/li&gt;

  &lt;li&gt;Open the code behind for ViewWebFormsMVP and add the following bolded code and delete the existing Inherits line: 
    &lt;br /&gt;

    &lt;div class="csharpcode"&gt;
      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;    Partial &lt;span class="kwrd"&gt;Class&lt;/span&gt; ViewWebformsMVP&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;       &lt;strong&gt; &lt;span class="kwrd"&gt;Inherits&lt;/span&gt; ModuleView(Of ViewWebformsMVPModel)&lt;/strong&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;strong&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Implements&lt;/span&gt; IViewWebformsMVP&lt;/strong&gt;&lt;/pre&gt;

      &lt;pre&gt;&lt;strong&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Implements&lt;/span&gt; Entities.Modules.IActionable&lt;/strong&gt;&lt;/pre&gt;
    &lt;/div&gt;
    &lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/li&gt;

  &lt;li&gt;Open the EditWebFormsMVP code behind and add the following bolded code: 
    &lt;br /&gt;

    &lt;div class="csharpcode"&gt;
      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;    Partial &lt;span class="kwrd"&gt;Class&lt;/span&gt; EditWebformsMVP&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Inherits&lt;/span&gt; ModuleView(Of EditWebformsMVPModel)&lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Implements&lt;/span&gt; IEditWebFormsMVP&lt;/pre&gt;
    &lt;/div&gt;
    &lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/li&gt;

  &lt;li&gt;Implement the interface by adding the following code: 
    &lt;br /&gt;

    &lt;div class="csharpcode"&gt;
      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; ShowAuditControl(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; show &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Boolean&lt;/span&gt;) &lt;span class="kwrd"&gt;Implements&lt;/span&gt; IEditWebFormsMVP.ShowAuditControl&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;            &lt;span class="kwrd"&gt;Throw&lt;/span&gt; &lt;span class="kwrd"&gt;New&lt;/span&gt; NotImplementedException()&lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt; &lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; ShowDeleteButton(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; show &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Boolean&lt;/span&gt;) &lt;span class="kwrd"&gt;Implements&lt;/span&gt; IEditWebFormsMVP.ShowDeleteButton&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;            &lt;span class="kwrd"&gt;Throw&lt;/span&gt; &lt;span class="kwrd"&gt;New&lt;/span&gt; NotImplementedException()&lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt; &lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Event&lt;/span&gt; Cancel &lt;span class="kwrd"&gt;As&lt;/span&gt; EventHandler &lt;span class="kwrd"&gt;Implements&lt;/span&gt; IEditWebFormsMVP.Cancel&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Event&lt;/span&gt; Delete &lt;span class="kwrd"&gt;As&lt;/span&gt; EventHandler &lt;span class="kwrd"&gt;Implements&lt;/span&gt; IEditWebFormsMVP.Delete&lt;/pre&gt;

      &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Event&lt;/span&gt; Save &lt;span class="kwrd"&gt;As&lt;/span&gt; EventHandler(Of UIEventArgs(Of WebformsMVPInfo)) &lt;span class="kwrd"&gt;Implements&lt;/span&gt; IEditWebFormsMVP.Save&lt;/pre&gt;
    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now the the views have their interfaces all wired up we still have a bit of work to do.  You’ll notice that the code behind files still have lots of code in the events for the buttons and load etc.  All of this code needs to be moved to the presenter classes as its code that needs to be tested.  Then we need to change the events to raise the event from the interface so the presenter can do its job.  To set up the presenter classes do the following:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Right click the Presenters folder and add two classes, one called EditWebformsMVPPresenter and the other called ViewWebformsMVPPresenter. &lt;/li&gt;

  &lt;li&gt;Add the name spaces. &lt;/li&gt;

  &lt;li&gt;The presenter class needs to inherit from the core WebFormsMVP presenter class.&lt;/li&gt;

  &lt;li&gt;The presenter also needs two constructors, add the following code in bold to set this up.  The first constructor is used in production and the second one is sued for test which allows you to pass in a mock controller for testing.
    &lt;br /&gt;&lt;/li&gt;

  &lt;div class="csharpcode"&gt;
    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;Namespace&lt;/span&gt; YourCompany.Modules.WebformsMVP&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;    &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Class&lt;/span&gt; ViewWebformsMVPPresenter&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;strong&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Inherits&lt;/span&gt; ModulePresenter(Of IViewWebformsMVP, ViewWebformsMVPModel)&lt;/strong&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;strong&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt; &lt;/strong&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;strong&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; &lt;span class="kwrd"&gt;New&lt;/span&gt;(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; _View &lt;span class="kwrd"&gt;As&lt;/span&gt; IViewWebformsMVP)&lt;/strong&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;strong&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;            &lt;span class="kwrd"&gt;Me&lt;/span&gt;.&lt;span class="kwrd"&gt;New&lt;/span&gt;(_View, &lt;span class="kwrd"&gt;New&lt;/span&gt; WebformsMVPController(&lt;span class="kwrd"&gt;New&lt;/span&gt; SqlDataProvider()))&lt;/strong&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;strong&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;&lt;/strong&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;strong&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt; &lt;/strong&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;strong&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; &lt;span class="kwrd"&gt;New&lt;/span&gt;(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; _View &lt;span class="kwrd"&gt;As&lt;/span&gt; IViewWebformsMVP, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; _Controller &lt;span class="kwrd"&gt;As&lt;/span&gt; IWebformsMVPController)&lt;/strong&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;strong&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;            &lt;span class="kwrd"&gt;MyBase&lt;/span&gt;.&lt;span class="kwrd"&gt;New&lt;/span&gt;(_View)&lt;/strong&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;strong&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;&lt;/strong&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Class&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;&lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Namespace&lt;/span&gt;&lt;/pre&gt;
  &lt;/div&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

  &lt;li&gt;Do the same for the EditWebFormsMVPPresenter
    &lt;br /&gt;&lt;/li&gt;

  &lt;div class="csharpcode"&gt;
    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;Namespace&lt;/span&gt; YourCompany.Modules.WebformsMVP&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;    &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Class&lt;/span&gt; EditWebformsMVPPresenter&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;strong&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Inherits&lt;/span&gt; ModulePresenter(Of IEditWebFormsMVP, EditWebformsMVPModel)&lt;/strong&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;strong&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt; &lt;/strong&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;strong&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; &lt;span class="kwrd"&gt;New&lt;/span&gt;(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; _View &lt;span class="kwrd"&gt;As&lt;/span&gt; IEditWebFormsMVP)&lt;/strong&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;strong&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;            &lt;span class="kwrd"&gt;Me&lt;/span&gt;.&lt;span class="kwrd"&gt;New&lt;/span&gt;(_View, &lt;span class="kwrd"&gt;New&lt;/span&gt; WebformsMVPController(&lt;span class="kwrd"&gt;New&lt;/span&gt; SqlDataProvider()))&lt;/strong&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;strong&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;&lt;/strong&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;strong&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt; &lt;/strong&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;strong&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; &lt;span class="kwrd"&gt;New&lt;/span&gt;(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; _View &lt;span class="kwrd"&gt;As&lt;/span&gt; IEditWebFormsMVP, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; _Controller &lt;span class="kwrd"&gt;As&lt;/span&gt; IWebformsMVPController)&lt;/strong&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;strong&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;            &lt;span class="kwrd"&gt;MyBase&lt;/span&gt;.&lt;span class="kwrd"&gt;New&lt;/span&gt;(_View)&lt;/strong&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Class&lt;/span&gt;&lt;/pre&gt;
  &lt;/div&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/ol&gt;

&lt;p&gt;The classes are now set up so the next step is to move the logic code from the code behind files into the presenter classes.  This is pretty much a Cut &amp; Paste operation with a few changes to use the View rather than controls directly.  The ViewWebFormsMVP is the simplest so let’s do that one first.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Cut the code inside the Page_Load event in the ViewWebFormsMVP.ascx.vb file.&lt;/li&gt;

  &lt;li&gt;Paste it into the second constructor directly after the MyBase.New(_View) line of code.&lt;/li&gt;

  &lt;li&gt;Change the lines of code that bind the List to the lstContent Datalist to assign the List to the View.Model.List.&lt;/li&gt;

  &lt;li&gt;Then change the ProcessModuleLoadException call to remove the Me from it as this is no longer needed as the base class puts that in.  The code looks like this:
    &lt;br /&gt;&lt;/li&gt;

  &lt;div class="csharpcode"&gt;
    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; &lt;span class="kwrd"&gt;New&lt;/span&gt;(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; _View &lt;span class="kwrd"&gt;As&lt;/span&gt; IViewWebformsMVP, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; _Controller &lt;span class="kwrd"&gt;As&lt;/span&gt; IWebformsMVPController)&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;            &lt;span class="kwrd"&gt;MyBase&lt;/span&gt;.&lt;span class="kwrd"&gt;New&lt;/span&gt;(_View)&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;            &lt;span class="kwrd"&gt;Try&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;                &lt;span class="kwrd"&gt;Dim&lt;/span&gt; objWebformsMVPs &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;New&lt;/span&gt; WebformsMVPController&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;                &lt;span class="kwrd"&gt;Dim&lt;/span&gt; colWebformsMVPs &lt;span class="kwrd"&gt;As&lt;/span&gt; List(Of WebformsMVPInfo)&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt; &lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;                &lt;span class="rem"&gt;' get the content from the WebformsMVP table&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;                colWebformsMVPs = objWebformsMVPs.GetWebformsMVPs(ModuleId)&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt; &lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;                &lt;span class="kwrd"&gt;If&lt;/span&gt; colWebformsMVPs.Count = 0 &lt;span class="kwrd"&gt;Then&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;                    &lt;span class="rem"&gt;' add the content to the WebformsMVP table&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;                    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; objWebformsMVP &lt;span class="kwrd"&gt;As&lt;/span&gt; WebformsMVPInfo = &lt;span class="kwrd"&gt;New&lt;/span&gt; WebformsMVPInfo&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;                    objWebformsMVP.ModuleId = ModuleId&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;                    objWebformsMVP.Content = Localization.GetString(&lt;span class="str"&gt;"DefaultContent"&lt;/span&gt;, LocalResourceFile)&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;                    objWebformsMVP.CreatedByUser = &lt;span class="kwrd"&gt;Me&lt;/span&gt;.UserId&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;                    objWebformsMVPs.AddWebformsMVP(objWebformsMVP)&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;                    &lt;span class="rem"&gt;' get the content from the WebformsMVP table&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;                    colWebformsMVPs = objWebformsMVPs.GetWebformsMVPs(ModuleId)&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;                &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt; &lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;                &lt;span class="rem"&gt;' bind the content to the repeater&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;                _View.Model.ListWebformsMVPInfo = colWebformsMVPs&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt; &lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;            &lt;span class="kwrd"&gt;Catch&lt;/span&gt; exc &lt;span class="kwrd"&gt;As&lt;/span&gt; Exception        &lt;span class="rem"&gt;'Module failed to load&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;                ProcessModuleLoadException(exc)&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;            &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Try&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;
  &lt;/div&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

  &lt;li&gt;For now comment out the lstContent_ItemDataBound method, I’ll come back to that later.&lt;/li&gt;

  &lt;li&gt;There is one last step to wire up the Vie to the Presenter.  In the ViewWebformsMVP.ascx.vb file you need to add an attribute to the class to tell it which Presenter it should use.  To do this add the bolded code to the class as shown below:
    &lt;br /&gt;&lt;/li&gt;

  &lt;div class="csharpcode"&gt;
    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;    &lt;strong&gt;&lt;PresenterBinding(&lt;span class="kwrd"&gt;GetType&lt;/span&gt;(ViewWebformsMVPPresenter))&gt;&lt;/strong&gt; _&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;    Partial &lt;span class="kwrd"&gt;Class&lt;/span&gt; ViewWebformsMVP&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Inherits&lt;/span&gt; ModuleView(Of ViewWebformsMVPModel)&lt;/pre&gt;
  &lt;/div&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/ol&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Now that the Presenter takes care of all the logic and it has no knowledge of the controls that the values it works with should go in the ascx file needs to be updated to use some one way data binding.  To do this set the DataSource property on the DataList control in the markup and then call Me.DataBind() in the Page_PreRender event.  Foolow these steps to accomplish this:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Set the DataSource property in the mark up as below&lt;/li&gt;

  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;asp:datalist&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="lstContent"&lt;/span&gt;  &lt;strong&gt;&lt;span class="attr"&gt;DataSource&lt;/span&gt;&lt;span class="kwrd"&gt;='&lt;%# Model.ListWebformsMVPInfo %&gt;'&lt;/span&gt;&lt;/strong&gt; 
       &lt;span class="attr"&gt;datakeyfield&lt;/span&gt;&lt;span class="kwrd"&gt;="ItemID"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="attr"&gt;cellpadding&lt;/span&gt;&lt;span class="kwrd"&gt;="4"&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

  &lt;li&gt;In the code behind file add the Page_PreRender event and tll the page to DataBind.
    &lt;br /&gt;&lt;/li&gt;

  &lt;div class="csharpcode"&gt;
    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; Page_PreRender(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; sender &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Object&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; e &lt;span class="kwrd"&gt;As&lt;/span&gt; System.EventArgs) &lt;span class="kwrd"&gt;Handles&lt;/span&gt; &lt;span class="kwrd"&gt;Me&lt;/span&gt;.PreRender&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;            &lt;span class="kwrd"&gt;Me&lt;/span&gt;.DataBind()&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;&lt;/pre&gt;
  &lt;/div&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

  &lt;li&gt;Next is to modify the ascx a bit more to use the Model properties.  The whole DataList looks like this:  Notice the use of ModuleContext, this is available in the base class and gives access to most of the DNN properties.
    &lt;br /&gt;&lt;/li&gt;

  &lt;div class="csharpcode"&gt;
    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;asp:datalist&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="lstContent"&lt;/span&gt;  &lt;span class="attr"&gt;DataSource&lt;/span&gt;&lt;span class="kwrd"&gt;='&lt;%# Model.ListWebformsMVPInfo %&gt;'&lt;/span&gt; &lt;span class="attr"&gt;datakeyfield&lt;/span&gt;&lt;span class="kwrd"&gt;="ItemID"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="attr"&gt;cellpadding&lt;/span&gt;&lt;span class="kwrd"&gt;="4"&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;ItemTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;        &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;table&lt;/span&gt; &lt;span class="attr"&gt;cellpadding&lt;/span&gt;&lt;span class="kwrd"&gt;="4"&lt;/span&gt; &lt;span class="attr"&gt;width&lt;/span&gt;&lt;span class="kwrd"&gt;="100%"&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;            &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;                &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt; &lt;span class="attr"&gt;valign&lt;/span&gt;&lt;span class="kwrd"&gt;="top"&lt;/span&gt; &lt;span class="attr"&gt;width&lt;/span&gt;&lt;span class="kwrd"&gt;="100%"&lt;/span&gt; &lt;span class="attr"&gt;align&lt;/span&gt;&lt;span class="kwrd"&gt;="left"&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;                    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;asp:HyperLink&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="HyperLink1"&lt;/span&gt; &lt;span class="attr"&gt;NavigateUrl&lt;/span&gt;&lt;span class="kwrd"&gt;='&lt;%# ModuleContext.EditURL("ItemID",DataBinder.Eval(Container.DataItem,"ItemID")) %&gt;'&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;                        &lt;span class="attr"&gt;Visible&lt;/span&gt;&lt;span class="kwrd"&gt;="&lt;%# Model.IsEditable %&gt;"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;                        &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;asp:Image&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="Image1"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="attr"&gt;ImageUrl&lt;/span&gt;&lt;span class="kwrd"&gt;="~/images/edit.gif"&lt;/span&gt; &lt;span class="attr"&gt;AlternateText&lt;/span&gt;&lt;span class="kwrd"&gt;="Edit"&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;                            &lt;span class="attr"&gt;Visible&lt;/span&gt;&lt;span class="kwrd"&gt;="&lt;%#Model.IsEditable%&gt;"&lt;/span&gt; &lt;span class="attr"&gt;resourcekey&lt;/span&gt;&lt;span class="kwrd"&gt;="Edit"&lt;/span&gt; &lt;span class="kwrd"&gt;/&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;asp:HyperLink&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;                    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;asp:Label&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="lblContent"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;='&lt;%# DataBinder.Eval(Container.DataItem,"DisplayContent") %&gt;'&lt;/span&gt; &lt;span class="attr"&gt;CssClass&lt;/span&gt;&lt;span class="kwrd"&gt;="Normal"&lt;/span&gt; &lt;span class="kwrd"&gt;/&gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;                &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;            &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;        &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;table&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;    &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;ItemTemplate&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;&lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;asp:datalist&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;
  &lt;/div&gt;
  &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/ol&gt;

&lt;p&gt;That's the ViewWebFormsMVP control finished.  The refactoring is relatively simple because you just move the code from the code behind to the presenter and change any references directly to controls to use the property on the View.Model.&lt;/p&gt;

&lt;p&gt;The process is the same for the EditWebFormsMVP control except that we have events to handle as well.  I won’t show all the code here as there is a lot.  I’ll show one event and how to pass the values from the View to the Presenter using the UIEventArgs.  Firstly let’s look at the UIEventArgs class, it’s very simple, it a normal EventArgs class with a generic property that you can add any object to.  In this example the generic will be the WebformsMVPInfo object.&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Class&lt;/span&gt; UIEventArgs(Of T)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;    &lt;span class="kwrd"&gt;Inherits&lt;/span&gt; EventArgs&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; &lt;span class="kwrd"&gt;New&lt;/span&gt;(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; item &lt;span class="kwrd"&gt;As&lt;/span&gt; T)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;        itemValue = item&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;    &lt;span class="kwrd"&gt;Private&lt;/span&gt; itemValue &lt;span class="kwrd"&gt;As&lt;/span&gt; T&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;    &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Property&lt;/span&gt; Item() &lt;span class="kwrd"&gt;As&lt;/span&gt; T&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Get&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;            &lt;span class="kwrd"&gt;Return&lt;/span&gt; itemValue&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Get&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Set&lt;/span&gt;(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; value &lt;span class="kwrd"&gt;As&lt;/span&gt; T)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;            itemValue = value&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Set&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Property&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;&lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Class&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;In the Edit presenter I need to know the ItemId that is to be edited which is in the QueryString.  To access the Request object you will need a refernce to System.Web.Abstractions.  Add a property to the presenter for ItemId like so:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;ReadOnly&lt;/span&gt; &lt;span class="kwrd"&gt;Property&lt;/span&gt; ItemId() &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Long&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;            &lt;span class="kwrd"&gt;Get&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;                &lt;span class="kwrd"&gt;Dim&lt;/span&gt; _ItemId &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt; = Null.NullInteger&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;                &lt;span class="kwrd"&gt;If&lt;/span&gt; &lt;span class="kwrd"&gt;Not&lt;/span&gt; &lt;span class="kwrd"&gt;String&lt;/span&gt;.IsNullOrEmpty(Request.Params(&lt;span class="str"&gt;"ItemId"&lt;/span&gt;)) &lt;span class="kwrd"&gt;Then&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;                    _ItemId = Int32.Parse(Request.Params(&lt;span class="str"&gt;"ItemId"&lt;/span&gt;))&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;                &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;                &lt;span class="kwrd"&gt;Return&lt;/span&gt; _ItemId&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;            &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Get&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Property&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;In the ViewWebFormsMVPPresenter I added the code to populate the Model in the constructor, this works fine because I don’t need anything from the Request.  However in the Edit presenter I need to know the ID of the item to be edited which is gathered from the QueryString therefore I can’t put the code in the constructor.  Instead the code goes into an Override for OnLoad.  Before I show you the code for that you will need to add a provate variable to hold the Controller class.&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="preproc"&gt;#Region&lt;/span&gt; &lt;span class="str"&gt;"Private Members"&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Private&lt;/span&gt; Controller &lt;span class="kwrd"&gt;As&lt;/span&gt; IWebformsMVPController&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&lt;span class="preproc"&gt;#End Region&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;The last thing to do before we add the OnLoad code is to add another constructor to the Info class so we can create a new one if the edit form is adding a new record.&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; &lt;span class="kwrd"&gt;New&lt;/span&gt;(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; mId &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; uId &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Integer&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;            ModuleId = mId&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;            ItemId = Null.NullInteger&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;            CreatedByUser = uId&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;            CreatedDate = Now&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Add the OnLoad code now by adding the following code:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Protected&lt;/span&gt; &lt;span class="kwrd"&gt;Overrides&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; OnLoad()&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;            &lt;span class="kwrd"&gt;MyBase&lt;/span&gt;.OnLoad()&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;            &lt;span class="kwrd"&gt;Try&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;                &lt;span class="kwrd"&gt;If&lt;/span&gt; &lt;span class="kwrd"&gt;Not&lt;/span&gt; DotNetNuke.Common.Utilities.Null.NullInteger = ItemId &lt;span class="kwrd"&gt;Then&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;                    &lt;span class="rem"&gt;' get content&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;                    &lt;span class="kwrd"&gt;Dim&lt;/span&gt; objTestDrivenDNNModule &lt;span class="kwrd"&gt;As&lt;/span&gt; WebformsMVPInfo = Controller.GetWebformsMVP(ModuleId, ItemId)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;                    &lt;span class="kwrd"&gt;If&lt;/span&gt; &lt;span class="kwrd"&gt;Not&lt;/span&gt; objTestDrivenDNNModule &lt;span class="kwrd"&gt;Is&lt;/span&gt; &lt;span class="kwrd"&gt;Nothing&lt;/span&gt; &lt;span class="kwrd"&gt;Then&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;                        View.Model.Item = objTestDrivenDNNModule&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;                    &lt;span class="kwrd"&gt;Else&lt;/span&gt; &lt;span class="rem"&gt;' security violation attempt to access item not related to this Module&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;                        Response.Redirect(NavigateURL())&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;                    &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;                &lt;span class="kwrd"&gt;Else&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;                    View.Model.Item = &lt;span class="kwrd"&gt;New&lt;/span&gt; WebformsMVPInfo(ModuleId, UserId)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;                    View.ShowDeleteButton(&lt;span class="kwrd"&gt;False&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;                    View.ShowAuditControl(&lt;span class="kwrd"&gt;False&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;                &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;            &lt;span class="kwrd"&gt;Catch&lt;/span&gt; exc &lt;span class="kwrd"&gt;As&lt;/span&gt; Exception&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;                ProcessModuleLoadException(exc)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;            &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Try&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;That takes care of loading the correct item into the View.Model.Item.  As with the ViewWebFormsMVP control the ascx markup needs to be updated to use one way databinding.  The change is very simple, just set the Text property to the Content property of the Item as shown in bold below:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;table&lt;/span&gt; &lt;span class="attr"&gt;width&lt;/span&gt;&lt;span class="kwrd"&gt;="650"&lt;/span&gt; &lt;span class="attr"&gt;cellspacing&lt;/span&gt;&lt;span class="kwrd"&gt;="0"&lt;/span&gt; &lt;span class="attr"&gt;cellpadding&lt;/span&gt;&lt;span class="kwrd"&gt;="0"&lt;/span&gt; &lt;span class="attr"&gt;border&lt;/span&gt;&lt;span class="kwrd"&gt;="0"&lt;/span&gt; &lt;span class="attr"&gt;summary&lt;/span&gt;&lt;span class="kwrd"&gt;="Edit Table"&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt; &lt;span class="attr"&gt;valign&lt;/span&gt;&lt;span class="kwrd"&gt;="top"&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;        &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt; &lt;span class="attr"&gt;class&lt;/span&gt;&lt;span class="kwrd"&gt;="SubHead"&lt;/span&gt; &lt;span class="attr"&gt;width&lt;/span&gt;&lt;span class="kwrd"&gt;="125"&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;dnn:label&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="lblContent"&lt;/span&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="attr"&gt;controlname&lt;/span&gt;&lt;span class="kwrd"&gt;="lblContent"&lt;/span&gt; &lt;span class="attr"&gt;suffix&lt;/span&gt;&lt;span class="kwrd"&gt;=":"&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;dnn:label&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;        &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;            &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;dnn:texteditor&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="txtContent"&lt;/span&gt; &lt;strong&gt;&lt;span class="attr"&gt;Text&lt;/span&gt;&lt;span class="kwrd"&gt;='&lt;%# Model.Item.Content %&gt;'&lt;/span&gt;&lt;/strong&gt; &lt;span class="attr"&gt;runat&lt;/span&gt;&lt;span class="kwrd"&gt;="server"&lt;/span&gt; &lt;span class="attr"&gt;height&lt;/span&gt;&lt;span class="kwrd"&gt;="200"&lt;/span&gt; &lt;span class="attr"&gt;width&lt;/span&gt;&lt;span class="kwrd"&gt;="500"&lt;/span&gt; &lt;span class="kwrd"&gt;/&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;            &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;asp:RequiredFieldValidator&lt;/span&gt; &lt;span class="attr"&gt;ID&lt;/span&gt;&lt;span class="kwrd"&gt;="valContent"&lt;/span&gt; &lt;span class="attr"&gt;resourcekey&lt;/span&gt;&lt;span class="kwrd"&gt;="valContent.ErrorMessage"&lt;/span&gt; &lt;span class="attr"&gt;ControlToValidate&lt;/span&gt;&lt;span class="kwrd"&gt;="txtContent"&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;                &lt;span class="attr"&gt;CssClass&lt;/span&gt;&lt;span class="kwrd"&gt;="NormalRed"&lt;/span&gt; &lt;span class="attr"&gt;Display&lt;/span&gt;&lt;span class="kwrd"&gt;="Dynamic"&lt;/span&gt; &lt;span class="attr"&gt;ErrorMessage&lt;/span&gt;="&amp;&lt;span class="attr"&gt;lt&lt;/span&gt;;&lt;span class="attr"&gt;br&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;Content is required" Runat="server" &lt;span class="kwrd"&gt;/&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;        &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;td&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;    &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;tr&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;&lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;table&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;There are only a couple of things left to do now, create the methods in the presenter that will fire when the events are activated, wire up those methods in the constructor and show you how to use the UIEventArgs in the Save method.  You’ll notice that the code is literally Cut &amp; Pasted from the code behind.&lt;/p&gt;

&lt;p&gt;Firstly add the following code to implement a method for the Cancel event:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; Cancel(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; sender &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Object&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; e &lt;span class="kwrd"&gt;As&lt;/span&gt; EventArgs)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;            Response.Redirect(NavigateURL())&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Now implement the Delete method:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; Delete(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; sender &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Object&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; e &lt;span class="kwrd"&gt;As&lt;/span&gt; EventArgs)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;            &lt;span class="kwrd"&gt;Try&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;                &lt;span class="rem"&gt;' Only attempt to delete the item if it exists already&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;                &lt;span class="kwrd"&gt;Dim&lt;/span&gt; objTestDrivenDNNModule &lt;span class="kwrd"&gt;As&lt;/span&gt; WebformsMVPInfo = Controller.GetWebformsMVP(ModuleId, ItemId)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;                &lt;span class="kwrd"&gt;If&lt;/span&gt; &lt;span class="kwrd"&gt;Not&lt;/span&gt; objTestDrivenDNNModule &lt;span class="kwrd"&gt;Is&lt;/span&gt; &lt;span class="kwrd"&gt;Nothing&lt;/span&gt; &lt;span class="kwrd"&gt;Then&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;                    Controller.DeleteWebformsMVP(ModuleId, ItemId)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;                    &lt;span class="rem"&gt;' Redirect back to the portal home page&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;                    Response.Redirect(NavigateURL())&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;                &lt;span class="kwrd"&gt;Else&lt;/span&gt; &lt;span class="rem"&gt;' security violation attempt to access item not related to this Module&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;                    Response.Redirect(NavigateURL())&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;                &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;            &lt;span class="kwrd"&gt;Catch&lt;/span&gt; exc &lt;span class="kwrd"&gt;As&lt;/span&gt; Exception&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;                &lt;span class="rem"&gt;'Show a UI message later&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;                ProcessModuleLoadException(exc)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;            &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Try&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;The Save method has a slightly different signature because it uses UIEventArgs.  However the code is just cut pasted from the code behind as well.&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; Save(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; sender &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Object&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; e &lt;span class="kwrd"&gt;As&lt;/span&gt; UIEventArgs(Of WebformsMVPInfo))&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;            &lt;span class="kwrd"&gt;Try&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;                e.Item.CreatedByUser = UserId&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;                e.Item.ModuleId = ModuleId&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;                e.Item.ItemId = ItemId&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;                &lt;span class="kwrd"&gt;If&lt;/span&gt; DotNetNuke.Common.Utilities.Null.NullInteger = ItemId &lt;span class="kwrd"&gt;Then&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;                    &lt;span class="rem"&gt;' add the content &lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;                    Controller.AddWebformsMVP(e.Item)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;                &lt;span class="kwrd"&gt;Else&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;                    &lt;span class="rem"&gt;' update the content &lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;                    Controller.UpdateWebformsMVP(e.Item)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;                &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;If&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;                &lt;span class="rem"&gt;' Redirect back to the portal home page&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;                Response.Redirect(NavigateURL())&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;            &lt;span class="kwrd"&gt;Catch&lt;/span&gt; exc &lt;span class="kwrd"&gt;As&lt;/span&gt; Exception    &lt;span class="rem"&gt;'Module failed to load&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;                ProcessModuleLoadException(exc)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;            &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Try&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; Sub&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;That’s the methods created now wire them up in the constructor like so:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; &lt;span class="kwrd"&gt;New&lt;/span&gt;(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; _View &lt;span class="kwrd"&gt;As&lt;/span&gt; IEditWebFormsMVP, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; _Controller &lt;span class="kwrd"&gt;As&lt;/span&gt; IWebformsMVPController)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;            &lt;span class="kwrd"&gt;MyBase&lt;/span&gt;.&lt;span class="kwrd"&gt;New&lt;/span&gt;(_View)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;strong&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;            Controller = _Controller&lt;/strong&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;strong&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;            &lt;span class="kwrd"&gt;AddHandler&lt;/span&gt; View.Cancel, &lt;span class="kwrd"&gt;AddressOf&lt;/span&gt; Cancel&lt;/strong&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;strong&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;            &lt;span class="kwrd"&gt;AddHandler&lt;/span&gt; View.Delete, &lt;span class="kwrd"&gt;AddressOf&lt;/span&gt; Delete&lt;/strong&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;strong&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;            &lt;span class="kwrd"&gt;AddHandler&lt;/span&gt; View.Save, &lt;span class="kwrd"&gt;AddressOf&lt;/span&gt; Save&lt;/strong&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Now change the code behind file so the events simple raise events for the presenter to listen to like so:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; cmdCancel_Click(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; sender &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Object&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; e &lt;span class="kwrd"&gt;As&lt;/span&gt; EventArgs) &lt;span class="kwrd"&gt;Handles&lt;/span&gt; cmdCancel.Click&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;            &lt;span class="kwrd"&gt;RaiseEvent&lt;/span&gt; Cancel(&lt;span class="kwrd"&gt;Me&lt;/span&gt;, e)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; cmdUpdate_Click(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; sender &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Object&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; e &lt;span class="kwrd"&gt;As&lt;/span&gt; EventArgs) &lt;span class="kwrd"&gt;Handles&lt;/span&gt; cmdUpdate.Click&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;            Model.Item = &lt;span class="kwrd"&gt;New&lt;/span&gt; WebformsMVPInfo()&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;            Model.Item.Content = txtContent.Text&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;            &lt;span class="kwrd"&gt;RaiseEvent&lt;/span&gt; Save(&lt;span class="kwrd"&gt;Me&lt;/span&gt;, &lt;span class="kwrd"&gt;New&lt;/span&gt; UIEventArgs(Of WebformsMVPInfo)(Model.Item))&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Private&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; cmdDelete_Click(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; sender &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Object&lt;/span&gt;, &lt;span class="kwrd"&gt;ByVal&lt;/span&gt; e &lt;span class="kwrd"&gt;As&lt;/span&gt; EventArgs) &lt;span class="kwrd"&gt;Handles&lt;/span&gt; cmdDelete.Click&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;            &lt;span class="kwrd"&gt;RaiseEvent&lt;/span&gt; Delete(&lt;span class="kwrd"&gt;Me&lt;/span&gt;, e)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;The very last thing to do is implement the two methods that control the visbility of the delete button and audit control.&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; ShowAuditControl(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; show &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Boolean&lt;/span&gt;) &lt;span class="kwrd"&gt;Implements&lt;/span&gt; IEditWebFormsMVP.ShowAuditControl&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;            ctlAudit.Visible = show&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt; ShowDeleteButton(&lt;span class="kwrd"&gt;ByVal&lt;/span&gt; show &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;Boolean&lt;/span&gt;) &lt;span class="kwrd"&gt;Implements&lt;/span&gt; IEditWebFormsMVP.ShowDeleteButton&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;            cmdDelete.Visible = show&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Sub&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Now build your project and, uh oh forgot to do something.  In the Actions menu code you need to add ModuleContext to the front of the EditURL and GetNextActionID like so:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;p&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;        &lt;span class="kwrd"&gt;Public&lt;/span&gt; &lt;span class="kwrd"&gt;ReadOnly&lt;/span&gt; &lt;span class="kwrd"&gt;Property&lt;/span&gt; ModuleActions() &lt;span class="kwrd"&gt;As&lt;/span&gt; Entities.Modules.Actions.ModuleActionCollection &lt;/p&gt;&lt;p&gt;                   &lt;span class="kwrd"&gt;Implements&lt;/span&gt; Entities.Modules.IActionable.ModuleActions&lt;/p&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;            &lt;span class="kwrd"&gt;Get&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;                &lt;span class="kwrd"&gt;Dim&lt;/span&gt; Actions &lt;span class="kwrd"&gt;As&lt;/span&gt; &lt;span class="kwrd"&gt;New&lt;/span&gt; Entities.Modules.Actions.ModuleActionCollection&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;                Actions.Add(ModuleContext.GetNextActionID, &lt;br /&gt;                         Localization.GetString(Entities.Modules.Actions.ModuleActionType.AddContent, LocalResourceFile), &lt;/pre&gt;

  &lt;pre&gt;                         Entities.Modules.Actions.ModuleActionType.AddContent, &lt;span class="str"&gt;""&lt;/span&gt;, &lt;span class="str"&gt;""&lt;/span&gt;, ModuleContext.EditUrl(), &lt;span class="kwrd"&gt;False&lt;/span&gt;, &lt;/pre&gt;

  &lt;pre&gt;                         Security.SecurityAccessLevel.Edit, &lt;span class="kwrd"&gt;True&lt;/span&gt;, &lt;span class="kwrd"&gt;False&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;                &lt;span class="kwrd"&gt;Return&lt;/span&gt; Actions&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;            &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Get&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;        &lt;span class="kwrd"&gt;End&lt;/span&gt; &lt;span class="kwrd"&gt;Property&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Now its all go :)  Your module is ready to rock and be tested which I’ll cover in Part 3.  The solution thus far is available &lt;a href="http://www.DotNetNuke.com/LinkClick.aspx?fileticket=Jz59EJU9Z8k%3d&amp;tabid=825"&gt;here&lt;/a&gt;. &lt;/p&gt;</description>
      <link>http://www.philipbeadle.net/Home/tabid/252/EntryId/626/Step-by-Step-Webforms-MVP-and-DotNetNuke-ndash-Part-2.aspx</link>
      <comments>http://www.philipbeadle.net/Home/tabid/252/EntryId/626/Step-by-Step-Webforms-MVP-and-DotNetNuke-ndash-Part-2.aspx#Comments</comments>
      <guid isPermaLink="true">http://www.philipbeadle.net/Home/tabid/252/EntryId/626/Step-by-Step-Webforms-MVP-and-DotNetNuke-ndash-Part-2.aspx</guid>
      <pubDate>Fri, 16 Apr 2010 00:45:58 GMT</pubDate>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://philipbeadle.net/DesktopModules/Blog/Trackback.aspx?id=626</trackback:ping>
    </item>
    <item>
      <title>Powershell script to install a DNN site from the zip</title>
      <description>&lt;p&gt;I wrote this script to help me be able to quickly run up a new auto installed DNN site from a zip file.  Check it out and please use yourself.&lt;/p&gt;  &lt;p&gt;#cd "C:\DotNetNuke\ProReleases"   &lt;br /&gt;cd "C:\DotNetNuke\Releases"    &lt;br /&gt;$CurrentLocation=get-location &lt;/p&gt;  &lt;p&gt;#$CEorPE ="Professional"   &lt;br /&gt;$CEorPE ="Community"    &lt;br /&gt;$version="050400"    &lt;br /&gt;$ZipFile = "$CurrentLocation\5.4.0\DotNetNuke_Community_5.4.0.94_Install.zip"    &lt;br /&gt;$websiteName = "DotNetNuke" + $CEorPE + $version + "Install"    &lt;br /&gt;$websiteAddress = "DotNetNuke" + $CEorPE + $version + ".Install"    &lt;br /&gt;$dbname = "DotNetNuke" + $CEorPE + $version + "Install"    &lt;br /&gt;$physicalPath = "DotNetNuke" + $CEorPE + $version + "Install" &lt;/p&gt;  &lt;p&gt;#remove existing IIS Site and App pool   &lt;br /&gt;Import-Module WebAdministration    &lt;br /&gt;Remove-Item iis:\Sites\$websiteName -Recurse    &lt;br /&gt;Remove-Item IIS:\AppPools\DotNetNukeAppPool -Recurse &lt;/p&gt;  &lt;p&gt;$shell=new-object -com shell.application &lt;/p&gt;  &lt;p&gt;$CurrentPath=$CurrentLocation.path &lt;/p&gt;  &lt;p&gt;$OutPutPath = "$CurrentPath\$physicalPath" &lt;/p&gt;  &lt;p&gt;$OutPutLocation=$shell.namespace($OutPutPath) &lt;/p&gt;  &lt;p&gt;#delete anything in the destination folder   &lt;br /&gt;new-item —force -path $OutPutPath -itemtype "directory"    &lt;br /&gt;get-childitem $OutPutPath | remove-item -force -recurse &lt;/p&gt;  &lt;p&gt;$ZipFolder = $shell.namespace($ZipFile) &lt;/p&gt;  &lt;p&gt;$OutPutLocation.Copyhere($ZipFolder.items()) &lt;/p&gt;  &lt;p&gt;#Set the ACL on the folder    &lt;br /&gt;$acl = Get-Acl $OutPutPath    &lt;br /&gt;$permission = "NETWORK SERVICE","FullControl","Allow"    &lt;br /&gt;$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission    &lt;br /&gt;$acl.SetAccessRule($accessRule)    &lt;br /&gt;Get-ChildItem $OutPutPath -Recurse -Force | Set-Acl -AclObject $acl &lt;/p&gt;  &lt;p&gt;#Create the IIS Site   &lt;br /&gt;New-Item IIS:\AppPools\DotNetNukeAppPool -Force &lt;/p&gt;  &lt;p&gt;Set-ItemProperty IIS:\AppPools\DotNetNukeAppPool -name ProcessModel.identityType -Value 2 &lt;/p&gt;  &lt;p&gt;New-Item iis:\Sites\$websiteName -bindings @{protocol="http";bindingInformation=":80:$websiteAddress"} -physicalPath $OutPutPath   &lt;br /&gt;Set-ItemProperty IIS:\Sites\$websiteName -name applicationPool -value DotNetNukeAppPool &lt;/p&gt;  &lt;p&gt;#Update the hosts file   &lt;br /&gt;$hostsentry = Select-String $Env:SystemRoot\System32\drivers\etc\hosts -pattern "$websiteAddress" -quiet    &lt;br /&gt;if (-not $hostsentry)    &lt;br /&gt;{    &lt;br /&gt;    Add-Content $Env:SystemRoot\System32\drivers\etc\hosts "127.0.0.1        $websiteAddress"    &lt;br /&gt;} &lt;/p&gt;  &lt;p&gt;#Now open IE and navigate to the site   &lt;br /&gt;$ie = new-object -com "InternetExplorer.Application" &lt;/p&gt;  &lt;p&gt;$ie.Visible = $true &lt;/p&gt;  &lt;p&gt;$ie.Navigate("&lt;a href="http://$websiteAddress/")"&gt;http://$websiteAddress/")&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;#some of the code below from &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc337896.aspx"&gt;http://msdn.microsoft.com/en-us/magazine/cc337896.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;$wait = $true   &lt;br /&gt;  $numWaits = 0    &lt;br /&gt;  while ($wait -and $numWaits -lt 100) {    &lt;br /&gt;    $numWaits++    &lt;br /&gt;    [System.Threading.Thread]::Sleep(500)    &lt;br /&gt;  $doc = $ie.Document    &lt;br /&gt;    if ($doc -ne $null) {    &lt;br /&gt;      $wait = $false    &lt;br /&gt;    }    &lt;br /&gt;    else {    &lt;br /&gt;      write-host "Waiting for app to respond $numWaits . . ."    &lt;br /&gt;    }    &lt;br /&gt;  }    &lt;br /&gt;  if ($numWaits -eq 100) {    &lt;br /&gt;    throw "Application did not respond after 100 delays"    &lt;br /&gt;  }    &lt;br /&gt;  else {    &lt;br /&gt;    write-host "Application has responded"    &lt;br /&gt;  }    &lt;br /&gt;$auto = $doc.getElementByID("wizInstall_rblInstall_2")    &lt;br /&gt;$auto.checked = $true    &lt;br /&gt;$nextBtn = $doc.getElementByID("wizInstall_StartNavigationTemplateContainerID_StartNextLinkButton")    &lt;br /&gt;$nextBtn.click()    &lt;br /&gt;[System.Threading.Thread]::Sleep(60000)    &lt;br /&gt;$ie.Navigate("&lt;a href="http://$websiteAddress/default.aspx")"&gt;http://$websiteAddress/default.aspx")&lt;/a&gt;&lt;/p&gt;</description>
      <link>http://www.philipbeadle.net/Home/tabid/252/EntryId/625/Powershell-script-to-install-a-DNN-site-from-the-zip.aspx</link>
      <comments>http://www.philipbeadle.net/Home/tabid/252/EntryId/625/Powershell-script-to-install-a-DNN-site-from-the-zip.aspx#Comments</comments>
      <guid isPermaLink="true">http://www.philipbeadle.net/Home/tabid/252/EntryId/625/Powershell-script-to-install-a-DNN-site-from-the-zip.aspx</guid>
      <pubDate>Wed, 14 Apr 2010 23:44:15 GMT</pubDate>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://philipbeadle.net/DesktopModules/Blog/Trackback.aspx?id=625</trackback:ping>
    </item>
    <item>
      <title>Step by Step Webforms MVP and DotNetNuke – Part 1.</title>
      <description>&lt;p&gt; This morning at the QA team meeting we discussed the &lt;a href="http://testdrivendnnmodule.codeplex.com/"&gt;&lt;font color="#1f8103"&gt;Testable DNN Module&lt;/font&gt;&lt;/a&gt; and its use of &lt;a href="http://webformsmvp.codeplex.com"&gt;&lt;font color="#2267a0"&gt;Webforms MVP&lt;/font&gt;&lt;/a&gt; to make it testable.  During the conversation we decided we needed some step by step information on how it all ties together in a “&lt;a href="http://www.dotnetnuke.com/Community/Blogs/tabid/825/BlogID/77/Default.aspx"&gt;&lt;font color="#2267a0"&gt;Michael Washington&lt;/font&gt;&lt;/a&gt;” style tutorial.  Charles Nurse has written up a great post on the theory behind the use of Webforms MVP &lt;a href="http://www.dotnetnuke.com/Community/Blogs/tabid/825/EntryId/2552/MVP-Module-Development-ndash-IModuleView-ModuleView-and-ModulePresenter.aspx"&gt;&lt;font color="#1f8103"&gt;here&lt;/font&gt;&lt;/a&gt;, so this tutorial will be more along the lines of what to do not why you do it.  Please make sure you read Charles’ post because I am assuming you have.&lt;/p&gt;&lt;a href=http://www.philipbeadle.net/Home/tabid/252/EntryId/624/Step-by-Step-Webforms-MVP-and-DotNetNuke-ndash-Part-1.aspx&gt;More...&lt;/a&gt;</description>
      <link>http://www.philipbeadle.net/Home/tabid/252/EntryId/624/Step-by-Step-Webforms-MVP-and-DotNetNuke-ndash-Part-1.aspx</link>
      <comments>http://www.philipbeadle.net/Home/tabid/252/EntryId/624/Step-by-Step-Webforms-MVP-and-DotNetNuke-ndash-Part-1.aspx#Comments</comments>
      <guid isPermaLink="true">http://www.philipbeadle.net/Home/tabid/252/EntryId/624/Step-by-Step-Webforms-MVP-and-DotNetNuke-ndash-Part-1.aspx</guid>
      <pubDate>Mon, 12 Apr 2010 02:47:17 GMT</pubDate>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://philipbeadle.net/DesktopModules/Blog/Trackback.aspx?id=624</trackback:ping>
    </item>
    <item>
      <title>How to build a fully Blendable and Testable Silverlight, RIA Services DNN Module – Part 4 – RIA Services</title>
      <description>&lt;p&gt;In Part 3 we did the basics of setting up MVVM for our module.  Now lets look at getting some data into our application using RIA Services.  It’s fairly straight forward to set up RIA Services as the Visual Studio templates do all the lifting for you.  Follow these steps to add RIA Services to your solution:&lt;/p&gt;  &lt;p&gt;Note: I have change the table name for the Announcements table to Announcement so that the generated class names and collections make more sense.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;We already added the project we are going to use so go to AnnouncementServices and Add a New Item and choose Linq to Sql Classes, and call it AnnouncementDataClasses.dbml.     &lt;br /&gt;You can use Entity Framework here if you prefer.      &lt;br /&gt;&lt;a href="http://philipbeadle.net/Portals/6/Blog/Files/3/621/WLW-HowtobuildafullyBlendableandTestableSilv_AEBE-image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="/Portals/6/Blog/Files/3/621/WLW-HowtobuildafullyBlendableandTestableSilv_AEBE-image_thumb.png" width="244" height="151" /&gt;&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Now open the Server Explorer and open your DotNetNuke database and drag the Announcement table onto the design surface.  You should see this;     &lt;br /&gt;&lt;a href="http://philipbeadle.net/Portals/6/Blog/Files/3/621/WLW-HowtobuildafullyBlendableandTestableSilv_AEBE-image_4.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="/Portals/6/Blog/Files/3/621/WLW-HowtobuildafullyBlendableandTestableSilv_AEBE-image_thumb_1.png" width="231" height="244" /&gt;&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Now build your solution.  You need to build it so that when we add the domain service the wizard can find the entity classes.&lt;/li&gt;    &lt;li&gt;Now add another new item called Domain Service Class and call it AnnouncementDomainService.cs     &lt;br /&gt;&lt;a href="http://philipbeadle.net/Portals/6/Blog/Files/3/621/WLW-HowtobuildafullyBlendableandTestableSilv_AEBE-image_6.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="/Portals/6/Blog/Files/3/621/WLW-HowtobuildafullyBlendableandTestableSilv_AEBE-image_thumb_2.png" width="244" height="151" /&gt;&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Check all the boxes so that you get the meta data class, Client Access and the CRUD methods     &lt;br /&gt;&lt;a href="http://philipbeadle.net/Portals/6/Blog/Files/3/621/WLW-HowtobuildafullyBlendableandTestableSilv_AEBE-image_8.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="/Portals/6/Blog/Files/3/621/WLW-HowtobuildafullyBlendableandTestableSilv_AEBE-image_thumb_3.png" width="231" height="244" /&gt;&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Add a reference from your web application MySilverlightApplication.Web to the AnnouncementServices project and build your application.&lt;/li&gt;    &lt;li&gt;Your solution explorer should look like this now     &lt;br /&gt;&lt;a href="http://philipbeadle.net/Portals/6/Blog/Files/3/621/WLW-HowtobuildafullyBlendableandTestableSilv_AEBE-image_10.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="/Portals/6/Blog/Files/3/621/WLW-HowtobuildafullyBlendableandTestableSilv_AEBE-image_thumb_4.png" width="189" height="244" /&gt;&lt;/a&gt; &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;You can see the “magic” file generated by the RIA Services link to your Silverlight Application.  Investigate this file and take note of the classes in there.  This is how we will communicate with the server from our client side application.  You can see that we have a partial class called Announcement which is an entity class.&lt;/p&gt;  &lt;p&gt;If you’re wondering how RIA Communicates with the server when havent made any Service References have a look at line 348:&lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; AnnouncementDomainContext() : &lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="kwrd"&gt;this&lt;/span&gt;(&lt;span class="kwrd"&gt;new&lt;/span&gt; HttpDomainClient(&lt;span class="kwrd"&gt;new&lt;/span&gt; Uri(&lt;span class="str"&gt;"DataService.axd/AnnouncementServices-AnnouncementDomainService/"&lt;/span&gt;, System.UriKind.Relative)))&lt;/pre&gt;

  &lt;pre class="alt"&gt;{&lt;/pre&gt;

  &lt;pre&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;RIA uses a httpHandler to manage the communication so you need to make sure that you update the web.config of your site.  Look at the app.config file in the AnnouncementServices project and copy the handler.  If you are using IIS 7+ you will need to also add the handler to the system.webserver section.  So add the following 2 items:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;This goes in system.web handlers section&lt;/pre&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;add&lt;/span&gt; &lt;span class="attr"&gt;path&lt;/span&gt;&lt;span class="kwrd"&gt;="DataService.axd"&lt;/span&gt; &lt;span class="attr"&gt;verb&lt;/span&gt;&lt;span class="kwrd"&gt;="GET,POST"&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="System.Web.Ria.DataServiceFactory, System.Web.Ria, Version=2.0.0.0, &lt;br /&gt;Culture=neutral, PublicKeyToken=31bf3856ad364e35"&lt;/span&gt; &lt;span class="attr"&gt;validate&lt;/span&gt;&lt;span class="kwrd"&gt;="false"&lt;/span&gt;&lt;span class="kwrd"&gt;/&gt;&lt;/span&gt;&lt;/pre&gt;

&lt;p&gt;and this goes in system.webserver handlers section&lt;span class="kwrd"&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class="kwrd"&gt;&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;add&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="DataService"&lt;/span&gt; &lt;span class="attr"&gt;verb&lt;/span&gt;&lt;span class="kwrd"&gt;="GET,POST"&lt;/span&gt; &lt;span class="attr"&gt;path&lt;/span&gt;&lt;span class="kwrd"&gt;="DataService.axd"&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="System.Web.Ria.DataServiceFactory, System.Web.Ria, 
    &lt;br /&gt;Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"&lt;/span&gt;&lt;span class="kwrd"&gt;/&gt;&lt;/span&gt;&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;The next step is to update our model so that it has a method to retrieve Announcement entities from the database.  &lt;/p&gt;

&lt;p&gt;Modify the IAnnouncementModel interface like so:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; MySilverlightApplication.Model&lt;/pre&gt;

  &lt;pre&gt;{&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;interface&lt;/span&gt; IAnnouncementsModel&lt;/pre&gt;

  &lt;pre&gt;    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;void&lt;/span&gt; GetAnnouncementList(Action&lt;IEnumerable&lt;Announcement&gt;&gt; action);&lt;/pre&gt;

  &lt;pre&gt;    }&lt;/pre&gt;

  &lt;pre class="alt"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Tip: If you are using ReSharper you can include the generated file in the project to help it find the generated classes.&lt;/p&gt;

&lt;p&gt;Now we need to implement the interface’s new method:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; MySilverlightApplication.Model&lt;/pre&gt;

  &lt;pre&gt;{&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; AnnouncementsModel : IAnnouncementsModel&lt;/pre&gt;

  &lt;pre&gt;    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; GetAnnouncementList(Action&lt;IEnumerable&lt;Announcement&gt;&gt; action)&lt;/pre&gt;

  &lt;pre&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;            var context = &lt;span class="kwrd"&gt;new&lt;/span&gt; AnnouncementDomainContext();&lt;/pre&gt;

  &lt;pre&gt;            var qry = context.GetAnnouncementsQuery().Where(a =&gt; a.ModuleID == 376);&lt;/pre&gt;

  &lt;pre class="alt"&gt;            context.Load(qry, op =&gt; action(op.Entities), &lt;span class="kwrd"&gt;null&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;        }&lt;/pre&gt;

  &lt;pre class="alt"&gt;    }&lt;/pre&gt;

  &lt;pre&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Now let’s write our first test.  We are going to write a test that tests to make sure we have two Announcement entities loaded into the ViewModel when create a new ViewModel.  We are going to do some TDD here so this test will fail until we write the minimum amount of production code to make it pass.&lt;/p&gt;

&lt;p&gt;Open up your MSTest project and change the UnitTest.cs file name to ViewModelTests.cs&lt;/p&gt;

&lt;p&gt;Now modify it so it looks like this:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; MySilverlightApplication.MSTest&lt;/pre&gt;

  &lt;pre&gt;{&lt;/pre&gt;

  &lt;pre class="alt"&gt;    [TestClass]&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ViewModelTests : SilverlightTest&lt;/pre&gt;

  &lt;pre class="alt"&gt;    {&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="kwrd"&gt;readonly&lt;/span&gt; MainPageViewModel _viewModel = &lt;span class="kwrd"&gt;new&lt;/span&gt; MainPageViewModel(&lt;span class="kwrd"&gt;new&lt;/span&gt; MockAnnouncementsModel());&lt;/pre&gt;

  &lt;pre class="alt"&gt; &lt;/pre&gt;

  &lt;pre&gt;        [TestMethod]&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ViewModelDataLoadsCorrectly()&lt;/pre&gt;

  &lt;pre&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;            Assert.AreEqual(2, _viewModel);&lt;/pre&gt;

  &lt;pre&gt;        }&lt;/pre&gt;

  &lt;pre class="alt"&gt;    }&lt;/pre&gt;

  &lt;pre&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Here you can see why we used two constructors on the MainPageViewModel class and why we instantiate it with an interface, so we can pass in our own MockAnnouncementsModel for testing.&lt;/p&gt;

&lt;p&gt;Run the test and it will fail because it doesnt make much sense yet.  What we need is something on the VM to hold a list of Announcement entities so lets add an ObservableCollection.  Add the following code to the ViewModel&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; ObservableCollection&lt;Announcement&gt; _announcements;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; ObservableCollection&lt;Announcement&gt; Announcements&lt;/pre&gt;

  &lt;pre class="alt"&gt;{&lt;/pre&gt;

  &lt;pre&gt;    get { &lt;span class="kwrd"&gt;return&lt;/span&gt; _announcements; }&lt;/pre&gt;

  &lt;pre class="alt"&gt;    set&lt;/pre&gt;

  &lt;pre&gt;    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;        _announcements = &lt;span class="kwrd"&gt;value&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="rem"&gt;//OnPropertyChanged("Announcements");&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    }&lt;/pre&gt;

  &lt;pre&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Don’t worry about the OnPropertyChanged bit yet, we’ll get to that soon.&lt;/p&gt;

&lt;p&gt;Ok so now we have somewhere to store our result lets populate it.  Add the following method:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; LoadModel()&lt;/pre&gt;

  &lt;pre&gt;{&lt;/pre&gt;

  &lt;pre class="alt"&gt;    _announcementsList.GetAnnouncementList(op =&gt;&lt;/pre&gt;

  &lt;pre&gt;    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;        Announcements = op.AsObservableCollection();&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (LoadComplete != &lt;span class="kwrd"&gt;null&lt;/span&gt;) LoadComplete(&lt;span class="kwrd"&gt;this&lt;/span&gt;, &lt;span class="kwrd"&gt;null&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre class="alt"&gt;    });&lt;/pre&gt;

  &lt;pre&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;I’m using an extension method here called AsObservableCollection because I’m always turning IEnumerable in AsObservable.  To do this add a new Silverlight class library project to your solution and call it Common.  Then add a class called Extensions and modify it as below:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; Common&lt;/pre&gt;

  &lt;pre&gt;{&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Extensions&lt;/pre&gt;

  &lt;pre&gt;    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; ObservableCollection&lt;T&gt; AsObservableCollection&lt;T&gt;(&lt;span class="kwrd"&gt;this&lt;/span&gt; System.Collections.Generic.IEnumerable&lt;T&gt; col)&lt;/pre&gt;

  &lt;pre&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;            var newcol = &lt;span class="kwrd"&gt;new&lt;/span&gt; ObservableCollection&lt;T&gt;();&lt;/pre&gt;

  &lt;pre&gt;            &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (var item &lt;span class="kwrd"&gt;in&lt;/span&gt; col)&lt;/pre&gt;

  &lt;pre class="alt"&gt;            {&lt;/pre&gt;

  &lt;pre&gt;                newcol.Add(item);&lt;/pre&gt;

  &lt;pre class="alt"&gt;            }&lt;/pre&gt;

  &lt;pre&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; newcol;&lt;/pre&gt;

  &lt;pre class="alt"&gt;        }&lt;/pre&gt;

  &lt;pre&gt;    }&lt;/pre&gt;

  &lt;pre class="alt"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Now add a reference to it from the MySilverlightApplication project and build your solution.&lt;/p&gt;

&lt;p&gt;Next we’ll modify the Mock data model class so it returns 2 Announcement entities.&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; MySilverlightApplication.MSTest&lt;/pre&gt;

  &lt;pre&gt;{&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;class&lt;/span&gt; MockAnnouncementsModel : IAnnouncementsModel&lt;/pre&gt;

  &lt;pre&gt;    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; GetAnnouncementList(Action&lt;IEnumerable&lt;Announcement&gt;&gt; action)&lt;/pre&gt;

  &lt;pre&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;            action(MockData());&lt;/pre&gt;

  &lt;pre&gt;        }&lt;/pre&gt;

  &lt;pre class="alt"&gt; &lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; IEnumerable&lt;Announcement&gt; MockData()&lt;/pre&gt;

  &lt;pre class="alt"&gt;        {&lt;/pre&gt;

  &lt;pre&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt;[]&lt;/pre&gt;

  &lt;pre class="alt"&gt;                  {&lt;/pre&gt;

  &lt;pre&gt;                    &lt;span class="kwrd"&gt;new&lt;/span&gt; Announcement()&lt;/pre&gt;

  &lt;pre class="alt"&gt;                    {&lt;/pre&gt;

  &lt;pre&gt;                      Title = &lt;span class="str"&gt;"Test Title 1"&lt;/span&gt;,&lt;/pre&gt;

  &lt;pre class="alt"&gt;                      CreatedDate = &lt;span class="kwrd"&gt;new&lt;/span&gt; DateTime(2009, 9, 9)&lt;/pre&gt;

  &lt;pre&gt;                    },&lt;/pre&gt;

  &lt;pre class="alt"&gt;                    &lt;span class="kwrd"&gt;new&lt;/span&gt; Announcement()&lt;/pre&gt;

  &lt;pre&gt;                    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;                      Title = &lt;span class="str"&gt;"Test Title 2"&lt;/span&gt;,&lt;/pre&gt;

  &lt;pre&gt;                      CreatedDate = &lt;span class="kwrd"&gt;new&lt;/span&gt; DateTime(2009, 9, 10)&lt;/pre&gt;

  &lt;pre class="alt"&gt;                    }&lt;/pre&gt;

  &lt;pre&gt;                  };&lt;/pre&gt;

  &lt;pre class="alt"&gt;        }&lt;/pre&gt;

  &lt;pre&gt;    }&lt;/pre&gt;

  &lt;pre class="alt"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Lastly modify the test so it calls the Load method and does it’s assert against the count of the collection like so:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;[TestMethod]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ViewModelDataLoadsCorrectly()&lt;/pre&gt;

  &lt;pre class="alt"&gt;{&lt;/pre&gt;

  &lt;pre&gt;    _viewModel.LoadModel();&lt;/pre&gt;

  &lt;pre class="alt"&gt;    Assert.AreEqual(2, _viewModel.Announcements.Count());&lt;/pre&gt;

  &lt;pre&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Run the test and you should get a nice green tick:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://philipbeadle.net/Portals/6/Blog/Files/3/621/WLW-HowtobuildafullyBlendableandTestableSilv_AEBE-image_12.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="/Portals/6/Blog/Files/3/621/WLW-HowtobuildafullyBlendableandTestableSilv_AEBE-image_thumb_5.png" width="239" height="244" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Righto, good news the test passes so now we can go to our DNN web site and have a look at the module.  Make sure you have some announcements in the database first :)&lt;/p&gt;

&lt;p&gt;Make sure you attach the debugger to the process and put a break point in the LoadModel so that you can see the results coming back properly.  Now if you’re wondering why the results don’t show up in the site that’s because we need to let the UI know that we have some results.  To do that we Implement INotifyPropertyChanged.  Since we will use this all over the place we’ll add it into the Common project.&lt;/p&gt;

&lt;p&gt;Add a new class called ViewModelBase and modify it to look like:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; Common&lt;/pre&gt;

  &lt;pre&gt;{&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; ViewModelBase : INotifyPropertyChanged&lt;/pre&gt;

  &lt;pre&gt;    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;event&lt;/span&gt; PropertyChangedEventHandler PropertyChanged;&lt;/pre&gt;

  &lt;pre&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OnPropertyChanged(&lt;span class="kwrd"&gt;params&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt;[] propertyNames)&lt;/pre&gt;

  &lt;pre&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;null&lt;/span&gt; == PropertyChanged)&lt;/pre&gt;

  &lt;pre&gt;                &lt;span class="kwrd"&gt;return&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (var each &lt;span class="kwrd"&gt;in&lt;/span&gt; propertyNames)&lt;/pre&gt;

  &lt;pre&gt;            {&lt;/pre&gt;

  &lt;pre class="alt"&gt;                PropertyChanged(&lt;span class="kwrd"&gt;this&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; PropertyChangedEventArgs(each));&lt;/pre&gt;

  &lt;pre&gt;            }&lt;/pre&gt;

  &lt;pre class="alt"&gt;        }&lt;/pre&gt;

  &lt;pre&gt;    }&lt;/pre&gt;

  &lt;pre class="alt"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Now go the MainPageViewModel class and make it inherit the new ViewModelBase class and then uncomment the OnPropertyChanged line.  Now rebuild and check your module.  You should get this:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://philipbeadle.net/Portals/6/Blog/Files/3/621/WLW-HowtobuildafullyBlendableandTestableSilv_AEBE-image_14.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="/Portals/6/Blog/Files/3/621/WLW-HowtobuildafullyBlendableandTestableSilv_AEBE-image_thumb_6.png" width="244" height="187" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Ok that’s it for Part 4, we looked at how to write a test for the View Model and how to hook up RIA services and get data into our UI.  Remember the code is available at CodePlex &lt;a title="http://dnnsilverlightria.codeplex.com/" href="http://dnnsilverlightria.codeplex.com/"&gt;http://dnnsilverlightria.codeplex.com/&lt;/a&gt;&lt;/p&gt;</description>
      <link>http://www.philipbeadle.net/Home/tabid/252/EntryId/621/How-to-build-a-fully-Blendable-and-Testable-Silverlight-RIA-Services-DNN-Module-ndash-Part-4-ndash-RIA-Services.aspx</link>
      <comments>http://www.philipbeadle.net/Home/tabid/252/EntryId/621/How-to-build-a-fully-Blendable-and-Testable-Silverlight-RIA-Services-DNN-Module-ndash-Part-4-ndash-RIA-Services.aspx#Comments</comments>
      <guid isPermaLink="true">http://www.philipbeadle.net/Home/tabid/252/EntryId/621/How-to-build-a-fully-Blendable-and-Testable-Silverlight-RIA-Services-DNN-Module-ndash-Part-4-ndash-RIA-Services.aspx</guid>
      <pubDate>Fri, 25 Sep 2009 03:50:52 GMT</pubDate>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://philipbeadle.net/DesktopModules/Blog/Trackback.aspx?id=621</trackback:ping>
    </item>
    <item>
      <title>Source code for Blendable and Testable Silverlight, RIA Services DNN Module on CodePlex</title>
      <description>&lt;p&gt;I have been adding the source code for this blog series on my Downloads page at each step and I also loaded it up to CodePlex. &lt;a title="http://dnnsilverlightria.codeplex.com/" href="http://dnnsilverlightria.codeplex.com/"&gt;http://dnnsilverlightria.codeplex.com/&lt;/a&gt;.  If you would like to contribute please contact me.&lt;/p&gt;</description>
      <link>http://www.philipbeadle.net/Home/tabid/252/EntryId/620/Source-code-for-Blendable-and-Testable-Silverlight-RIA-Services-DNN-Module-on-CodePlex.aspx</link>
      <comments>http://www.philipbeadle.net/Home/tabid/252/EntryId/620/Source-code-for-Blendable-and-Testable-Silverlight-RIA-Services-DNN-Module-on-CodePlex.aspx#Comments</comments>
      <guid isPermaLink="true">http://www.philipbeadle.net/Home/tabid/252/EntryId/620/Source-code-for-Blendable-and-Testable-Silverlight-RIA-Services-DNN-Module-on-CodePlex.aspx</guid>
      <pubDate>Thu, 24 Sep 2009 20:45:24 GMT</pubDate>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://philipbeadle.net/DesktopModules/Blog/Trackback.aspx?id=620</trackback:ping>
    </item>
    <item>
      <title>How to build a fully Blendable and Testable Silverlight, RIA Services DNN Module – Part 3 - MVVM</title>
      <description>&lt;p&gt;So we’re all set to write some code now.  I will be using the MVVM pattern to separate the concerns and to make the logic testable.  MVVM stands for Model – View – View Model, the View is the MainPage.xaml, the View Model will be MainPage.vm.cs and the Model will be our list of announcements.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Add a new Silverlight class to the MySilverlightApplication project and call it MainPage.vm.cs, this will be the code file for the View Model.     &lt;br /&gt;I have a registry entry that assocaites my MainPage.vm.cs file with my MainPage.xaml.cs file the same way the MainPage.xaml.cs file is associated.  It looks like this for my 64 bit machine      &lt;br /&gt;      &lt;br /&gt;Windows Registry Editor Version 5.00 &lt;/li&gt;    &lt;p&gt;[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\9.0\Projects\{FAE04EC0-301F-11d3-BF4B-00C04F79EFBC}\RelatedFiles\.xaml]     &lt;br /&gt;".xaml.cs"=dword:00000039      &lt;br /&gt;".cs"=dword:00000002      &lt;br /&gt;".vm.cs"=dword:00000039      &lt;br /&gt;".design.cs"=dword:00000039&lt;/p&gt;    &lt;li&gt;Change the name of the class to MainPageViewModel,&lt;/li&gt;    &lt;li&gt;Now we need to set up our Model which will use an interface so we can easily swap out the model into our View Model for testing.&lt;/li&gt;    &lt;ol&gt;     &lt;li&gt;Add a folder called Model,&lt;/li&gt;      &lt;li&gt;Add a class called IAnnouncementsModel, it’s actually an interface so you’ll need to change it from a class to interface.&lt;/li&gt;      &lt;li&gt;Your interface should look like this:       &lt;br /&gt;&lt;/li&gt;      &lt;div class="csharpcode"&gt;       &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; MySilverlightApplication.Model&lt;/pre&gt;

      &lt;pre&gt;{&lt;/pre&gt;

      &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;interface&lt;/span&gt; IAnnouncementsModel&lt;/pre&gt;

      &lt;pre&gt;    {&lt;/pre&gt;

      &lt;pre class="alt"&gt;    }&lt;/pre&gt;

      &lt;pre&gt;}&lt;/pre&gt;
    &lt;/div&gt;
    &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

    &lt;li&gt;Now we need a concrete implementation of this so add another class called AnnouncementsModel that implements this interface.&lt;/li&gt;

    &lt;li&gt;Your class should look like this:
      &lt;br /&gt;&lt;/li&gt;

    &lt;div class="csharpcode"&gt;
      &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; MySilverlightApplication.Model&lt;/pre&gt;

      &lt;pre&gt;{&lt;/pre&gt;

      &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; AnnouncementsModel : IAnnouncementsModel&lt;/pre&gt;

      &lt;pre&gt;    {&lt;/pre&gt;

      &lt;pre class="alt"&gt; &lt;/pre&gt;

      &lt;pre&gt;    }&lt;/pre&gt;
    &lt;/div&gt;
    &lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/ol&gt;
&lt;/ol&gt;

&lt;p&gt;That's the model setup for now, we’ll add methods to it a bit later, let’s wire up the View Model with our model now.  We will provide two constructors for the View Model.  One will be used when we test it and the other will be used when it runs normally.  Edit your View Model class to look like the following:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; MySilverlightApplication&lt;/pre&gt;

  &lt;pre&gt;{&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; MainPageViewModel&lt;/pre&gt;

  &lt;pre&gt;    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;readonly&lt;/span&gt; IAnnouncementsModel _announcementsList;&lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;event&lt;/span&gt; EventHandler LoadComplete;&lt;/pre&gt;

  &lt;pre class="alt"&gt; &lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; MainPageViewModel()&lt;/pre&gt;

  &lt;pre class="alt"&gt;            : &lt;span class="kwrd"&gt;this&lt;/span&gt;(&lt;span class="kwrd"&gt;new&lt;/span&gt; AnnouncementsModel())&lt;/pre&gt;

  &lt;pre&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;        }&lt;/pre&gt;

  &lt;pre&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; MainPageViewModel(IAnnouncementsModel announcementsList)&lt;/pre&gt;

  &lt;pre&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;            _announcementsList = announcementsList;&lt;/pre&gt;

  &lt;pre&gt;        }&lt;/pre&gt;

  &lt;pre class="alt"&gt;    }&lt;/pre&gt;

  &lt;pre&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;The last thing we need to do is to tell the View to set its DataContext to the ViewModel at runtime.  We only want this to occur outside of Blend so the following test will load our VM at runtime and will use the SampleData in Blend.&lt;/p&gt;

&lt;p&gt;Change the code behind file for MainPage.xaml.cs to look like the following:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; MySilverlightApplication&lt;/pre&gt;

  &lt;pre&gt;{&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;partial&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; MainPage : UserControl&lt;/pre&gt;

  &lt;pre&gt;    {&lt;/pre&gt;

  &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; MainPage()&lt;/pre&gt;

  &lt;pre&gt;        {&lt;/pre&gt;

  &lt;pre class="alt"&gt;            InitializeComponent();&lt;/pre&gt;

  &lt;pre&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (!System.ComponentModel.DesignerProperties.IsInDesignTool)&lt;/pre&gt;

  &lt;pre class="alt"&gt;            {&lt;/pre&gt;

  &lt;pre&gt;                DataContext = &lt;span class="kwrd"&gt;new&lt;/span&gt; MainPageViewModel();&lt;/pre&gt;

  &lt;pre class="alt"&gt;            }&lt;/pre&gt;

  &lt;pre&gt;        }&lt;/pre&gt;

  &lt;pre class="alt"&gt;    }&lt;/pre&gt;

  &lt;pre&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;So that’s our MVVM pattern set up.  In Part 4 we will look at creating the RIA Service for the Announcements and doing some testing of our ViewModel.&lt;/p&gt;

&lt;p&gt;The files for these parts are available on the Downloads page of this site.&lt;/p&gt;</description>
      <link>http://www.philipbeadle.net/Home/tabid/252/EntryId/619/How-to-build-a-fully-Blendable-and-Testable-Silverlight-RIA-Services-DNN-Module-ndash-Part-3-MVVM.aspx</link>
      <comments>http://www.philipbeadle.net/Home/tabid/252/EntryId/619/How-to-build-a-fully-Blendable-and-Testable-Silverlight-RIA-Services-DNN-Module-ndash-Part-3-MVVM.aspx#Comments</comments>
      <guid isPermaLink="true">http://www.philipbeadle.net/Home/tabid/252/EntryId/619/How-to-build-a-fully-Blendable-and-Testable-Silverlight-RIA-Services-DNN-Module-ndash-Part-3-MVVM.aspx</guid>
      <pubDate>Thu, 24 Sep 2009 07:23:50 GMT</pubDate>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://philipbeadle.net/DesktopModules/Blog/Trackback.aspx?id=619</trackback:ping>
    </item>
    <item>
      <title>How to build a fully Blendable and Testable Silverlight, RIA Services DNN Module – Part 2 - Blendability</title>
      <description>&lt;p&gt;Now that you have your modules registered place it on a page.  You should see your module with an empty Silverlight control inside it.  Now switch to the settigns for the module and hit the checkbox to change it to load the SLTest Silverlight control.  This will execute the one test that is in teh file at this point and it will fail giving you the following result.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://philipbeadle.net/Portals/6/Blog/Files/3/618/WLW-HowtobuildafullyBlendableandTestableSilv_DEEC-image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="/Portals/6/Blog/Files/3/618/WLW-HowtobuildafullyBlendableandTestableSilv_DEEC-image_thumb.png" width="244" height="107" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;As you can see the testing results panel shows up as it is conducting the tests and gives you the result.  This is an excellent way to create integration tests for your module and it makes it very easy to ensure that as you code you are keeping your quality high and not introducing any new issues.  You can try out debugging at this point as well.  In the SLTest project add a break point to the Initialize event and then do Attach to process and select the Silverlight process like so.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://philipbeadle.net/Portals/6/Blog/Files/3/618/WLW-HowtobuildafullyBlendableandTestableSilv_DEEC-image_4.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="/Portals/6/Blog/Files/3/618/WLW-HowtobuildafullyBlendableandTestableSilv_DEEC-image_thumb_1.png" width="244" height="169" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Let’s get into designing our Announcements list.  The idea is that this module will replace the existing Announcements module.  So we will re-implement the same functionality starting off with listing the items in a nice list.  To do this we will use Expression Blend and use the cool new Sample Data feature.  Follow these steps:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Right click the MainPage.xaml file and select Open In Expression Blend, &lt;/li&gt;    &lt;li&gt;Add a ListBox control to the page and set its margins to 8 all around, &lt;/li&gt;    &lt;li&gt;Select the Data Tab, &lt;/li&gt;    &lt;li&gt;Click “Define new Sample Data”, &lt;/li&gt;    &lt;li&gt;Uncheck the “Enable smale data when application is running”, we don’t want sample data then we will have our own data from the database.  Unchecking this makes Silverlight ignore the sample data at run time which is exactly what we want to happen. &lt;/li&gt;    &lt;li&gt;Select Ok. &lt;/li&gt;    &lt;li&gt;You will now have the Sample data showing in the Data Tab.  Change the name from Collection to Announcements, this will be the name for our real data collection as well that we will use RIA to retrieve later. &lt;/li&gt;    &lt;li&gt;Now change the property names to match the fields in the Announcements table in your DNN database.  You may need to install the standard DNN Announcements module to see this table.  You only need to add the properties for the fields you want to show in the list here.      &lt;ol&gt;       &lt;li&gt;Make sure you set the property names exactly as they are in the database.  &lt;/li&gt;        &lt;li&gt;You can change the sample data by clicking the symbol to the right of the property name.  Set the Title property to be String – Name, set the CreatedDate to String – Date etc. &lt;/li&gt;     &lt;/ol&gt;   &lt;/li&gt;    &lt;li&gt;Now select the Announcements Collection and drag it onto the ListBox.  Its hould now look like the following      &lt;br /&gt;&lt;a href="http://philipbeadle.net/Portals/6/Blog/Files/3/618/WLW-HowtobuildafullyBlendableandTestableSilv_DEEC-image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="/Portals/6/Blog/Files/3/618/WLW-HowtobuildafullyBlendableandTestableSilv_DEEC-image_thumb_2.png" width="244" height="191" /&gt;&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;When you drag on the collection Blend adds a DataContext to the LayoutRoot grid.  Remove this text in the xaml      &lt;br /&gt;      &lt;p&gt;d:DataContext="{Binding Source={StaticResource SampleDataSource}}"        &lt;br /&gt;        &lt;br /&gt;and move it into the UserControl declaration as shown below:         &lt;br /&gt;&lt;/p&gt;      &lt;div class="csharpcode"&gt;       &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;UserControl&lt;/span&gt; &lt;span class="attr"&gt;x:Class&lt;/span&gt;&lt;span class="kwrd"&gt;="MySilverlightApplication.MainPage"&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;    &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt; &lt;/pre&gt;

      &lt;pre class="alt"&gt;    &lt;span class="attr"&gt;xmlns:x&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;    &lt;span class="attr"&gt;xmlns:d&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/expression/blend/2008"&lt;/span&gt; &lt;/pre&gt;

      &lt;pre class="alt"&gt;    &lt;span class="attr"&gt;xmlns:mc&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.openxmlformats.org/markup-compatibility/2006"&lt;/span&gt; &lt;/pre&gt;

      &lt;pre&gt;    &lt;strong&gt;&lt;span class="attr"&gt;d:DataContext&lt;/span&gt;&lt;span class="kwrd"&gt;="{Binding Source={StaticResource SampleDataSource}}"&lt;/span&gt;&lt;/strong&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;    &lt;span class="attr"&gt;mc:Ignorable&lt;/span&gt;&lt;span class="kwrd"&gt;="d"&lt;/span&gt; &lt;span class="attr"&gt;d:DesignWidth&lt;/span&gt;&lt;span class="kwrd"&gt;="640"&lt;/span&gt; &lt;span class="attr"&gt;d:DesignHeight&lt;/span&gt;&lt;span class="kwrd"&gt;="480"&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;
    &lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Ok you are now set up to design the ListBox as you see fit.  Have some fun with Blend, you can easily edit how the ListBox looks by right clicking it and selecting “Edit Additional Templates” –&gt; “Edit Generated Items” –&gt; “Edit Current”.  You are now in template editing mode and can edit the items template to your hearts content.&lt;/p&gt;

&lt;p&gt;Om so now you can see a nicely formatted list of items in Blend.  Try going back to Visual Studio rebuilding your application and checking it out in runtime mode.  You’ll see there are no items in the list :)  This is what is called Blendability, your designer can now design away and create a beautiful interface with nice sample data that doesnt interfere with the application when it is running in production.&lt;/p&gt;

&lt;p&gt;That’s it for Part 2.  In Part 3 we will look at using the MVVM pattern to make our application easily testable and we’ll get some real data into our list.&lt;/p&gt;</description>
      <link>http://www.philipbeadle.net/Home/tabid/252/EntryId/618/How-to-build-a-fully-Blendable-and-Testable-Silverlight-RIA-Services-DNN-Module-ndash-Part-2-Blendability.aspx</link>
      <comments>http://www.philipbeadle.net/Home/tabid/252/EntryId/618/How-to-build-a-fully-Blendable-and-Testable-Silverlight-RIA-Services-DNN-Module-ndash-Part-2-Blendability.aspx#Comments</comments>
      <guid isPermaLink="true">http://www.philipbeadle.net/Home/tabid/252/EntryId/618/How-to-build-a-fully-Blendable-and-Testable-Silverlight-RIA-Services-DNN-Module-ndash-Part-2-Blendability.aspx</guid>
      <pubDate>Thu, 24 Sep 2009 06:52:12 GMT</pubDate>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://philipbeadle.net/DesktopModules/Blog/Trackback.aspx?id=618</trackback:ping>
    </item>
    <item>
      <title>How to build a fully Blendable and Testable Silverlight, RIA Services DNN Module – Part 1 Setting up</title>
      <description>&lt;p&gt;This series of posts will show you a bunch of things I have learnt about building integrated Silverlight – DotNetNuke modules with RIA Services&lt;/p&gt;  &lt;p&gt;Projects to add:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Add a new Silverlight Project.  Call it MySilverlightApplication. &lt;/li&gt;    &lt;li&gt;Select to host it in a new Web Application called MySilverlightApplication.Web and check the Enable RIA Services link. &lt;/li&gt;    &lt;li&gt;Add a new Silverlight Unit Testing project and call it MySilverlightApplication.SLtest. &lt;/li&gt;    &lt;li&gt;Add a new Unit Test Project and call it MySilverlightApplication.MSTest &lt;/li&gt;    &lt;li&gt;Create a Solution Folder called Modules and move these four projects into it. &lt;/li&gt;    &lt;li&gt;Create another solution folder and call it Services. &lt;/li&gt;    &lt;li&gt;Add a new .Net class library (not a Silverlight one) and call it AuthenticationServices &lt;/li&gt;    &lt;li&gt;Our module is going to interact with the Announcements table so add another .Net class library and call it AnnouncementServices &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Ok we now have all the projects we need to build a fully testable and Blendable Silverlight Application for DotNetNuke.  Let’s do a little cleaning up and get everything ready for easy designing, testing and developing.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Delete the .aspx and .html files from the MySilverlightApplication.Web project. &lt;/li&gt;    &lt;li&gt;Click on the web.config file and set the build action to None.  The DNN site already has a web.config. &lt;/li&gt;    &lt;li&gt;Click on the Silverlight.js file and set the Copy To Output Directory to Copy If Newer. &lt;/li&gt;    &lt;li&gt;Open double click teh Properties node in teh Solution Explorer and add the MySilverlightApplication.SLtest project as a linked Silverlight Application. &lt;/li&gt;    &lt;li&gt;Add a new Folder to the MySilverlightApplication.SLtest called Dependencies and add the Microsoft.Silverlight.Testing.dll and Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll files to it.  &lt;/li&gt;    &lt;li&gt;Now add references to those two files so that your Silverlight Test project builds. &lt;/li&gt;    &lt;li&gt;Open the MSTest project and remove the references to System and System.Core, we need to replace these with the Silverlight specific versions. &lt;/li&gt;    &lt;li&gt;Add a reference to C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v3.0\system.dll.  You will also need references to System.Core, System.Net and System.Windows which are all in the same folder. &lt;/li&gt;    &lt;li&gt;Also add a reference to the same two dlls as in step 5 and to C:\Program Files (x86)\Microsoft SDKs\RIA Services\v1.0\Libraries\Silverlight\System.Windows.Ria.dll &lt;/li&gt;    &lt;li&gt;Now to both the SLTest and MSTest projects ad a reference to the Silverlight Application. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Everything should be building ok now so let’s make some changes to the .csproj files so that the correct files are deployed to our Development DotNetNuke site for easy debugging and automated integration testing.&lt;/p&gt;  &lt;p&gt;For debugging we need the .xap, .dll and .pdb files to be deployed onto the Development DNN instance, to do this I modify the .csproj files to do a copy after the build is finished.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Right click the MySilverlightApplication and select Unload Project. &lt;/li&gt;    &lt;li&gt;Right click it again and select Edit which will open the MSBuild file for the project. &lt;/li&gt;    &lt;li&gt;Towards the bottom of the file you will see some commented out code.  Paste the following immediately after that code. &lt;/li&gt; &lt;/ol&gt;  &lt;div class="csharpcode"&gt;   &lt;pre class="alt"&gt;  &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;Target&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;="AfterBuild"&lt;/span&gt; &lt;span class="attr"&gt;DependsOnTargets&lt;/span&gt;&lt;span class="kwrd"&gt;="DeployModule"&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;          &lt;span class="attr"&gt;Condition&lt;/span&gt;&lt;span class="kwrd"&gt;=" '$(IsDesktopBuild)'!='false' "&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;  &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;Target&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;  &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;PropertyGroup&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;DNNDirectory&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;      D:\DotNetNuke\DotNetNuke_Community_05.01.01_Install&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;DNNDirectory&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;ModuleFolder&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;      MySilverlightApplication&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;ModuleFolder&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;  &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;PropertyGroup&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;  &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;Target&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;="DeployModule"&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;CreateItem&lt;/span&gt; &lt;span class="attr"&gt;Include&lt;/span&gt;&lt;span class="kwrd"&gt;="$(MSBuildProjectDirectory)\$(OutputPath)\*.xap"&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;      &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;Output&lt;/span&gt; &lt;span class="attr"&gt;TaskParameter&lt;/span&gt;&lt;span class="kwrd"&gt;="Include"&lt;/span&gt; &lt;span class="attr"&gt;ItemName&lt;/span&gt;&lt;span class="kwrd"&gt;="ModuleXap"&lt;/span&gt; &lt;span class="kwrd"&gt;/&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;CreateItem&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;CreateItem&lt;/span&gt; &lt;span class="attr"&gt;Include&lt;/span&gt;&lt;span class="kwrd"&gt;="$(MSBuildProjectDirectory)\$(OutputPath)\*.dll"&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;      &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;Output&lt;/span&gt; &lt;span class="attr"&gt;TaskParameter&lt;/span&gt;&lt;span class="kwrd"&gt;="Include"&lt;/span&gt; &lt;span class="attr"&gt;ItemName&lt;/span&gt;&lt;span class="kwrd"&gt;="ModuleAssemblies"&lt;/span&gt; &lt;span class="kwrd"&gt;/&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;CreateItem&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;CreateItem&lt;/span&gt; &lt;span class="attr"&gt;Include&lt;/span&gt;&lt;span class="kwrd"&gt;="$(MSBuildProjectDirectory)\$(OutputPath)\*.pdb"&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;      &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;Output&lt;/span&gt; &lt;span class="attr"&gt;TaskParameter&lt;/span&gt;&lt;span class="kwrd"&gt;="Include"&lt;/span&gt; &lt;span class="attr"&gt;ItemName&lt;/span&gt;&lt;span class="kwrd"&gt;="ModuleDebug"&lt;/span&gt; &lt;span class="kwrd"&gt;/&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;CreateItem&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;Copy&lt;/span&gt; &lt;span class="attr"&gt;SourceFiles&lt;/span&gt;&lt;span class="kwrd"&gt;="@(ModuleAssemblies);@(ModuleDebug);@(ModuleXap)"&lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;          &lt;span class="attr"&gt;DestinationFolder&lt;/span&gt;&lt;span class="kwrd"&gt;="$(DNNDirectory)\DesktopModules\$(ModuleFolder)\ClientBin"&lt;/span&gt; &lt;span class="kwrd"&gt;/&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;  &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;Target&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Make sure you update the DNNDirectory and the ModuleFolder to your required values.  Do exactly the same for the SLTest project as well.  The condition in the Target is there so that this step is ignored when the solution is built with Team Foundation Server Build.&lt;/p&gt;

&lt;p&gt;We need to do a very similar modification to the Web project as well.  There is a slight difference here in that this change also packages up the appropriate files and creates the .zip file for install and source and a total package as well so every time you build you have a deployable .zip file ready to install on any other DotNetNuke site.  You will need to install the MSBuild Community Tasks from to use the Zip target.&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Install the MSBuild Community Tasks &lt;/li&gt;

  &lt;li&gt;Paste the following Immediately after the commented out code as before. &lt;/li&gt;
&lt;/ol&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre class="alt"&gt;  &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;Import&lt;/span&gt; &lt;span class="attr"&gt;Project&lt;/span&gt;&lt;span class="kwrd"&gt;="$(MSBuildExtensionsPath)\&lt;/pre&gt;

  &lt;pre&gt;       MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"&lt;/span&gt; &lt;span class="kwrd"&gt;/&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;  &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;Target&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;="AfterBuild"&lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;        &lt;span class="attr"&gt;DependsOnTargets&lt;/span&gt;&lt;span class="kwrd"&gt;="DeployModule"&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;  &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;Target&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;  &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;PropertyGroup&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;Major&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;01&lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;Major&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;Minor&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;00&lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;Minor&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;Build&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;00&lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;Build&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;  &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;PropertyGroup&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;  &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;PropertyGroup&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;ModuleFolder&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;      CHEAPLiveCosts&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;ModuleFolder&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;DNNDirectory&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;      C:\Sandboxes\CHEAP\CHEAP_Development&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;DNNDirectory&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;PackageDirectory&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;      C:\DotNetNuke\Packages&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;PackageDirectory&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;  &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;PropertyGroup&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;  &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;Target&lt;/span&gt; &lt;span class="attr"&gt;Name&lt;/span&gt;&lt;span class="kwrd"&gt;="DeployModule"&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;CreateItem&lt;/span&gt; &lt;span class="attr"&gt;Include&lt;/span&gt;&lt;span class="kwrd"&gt;="$(MSBuildProjectDirectory)\$(OutputPath)\*.dll"&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;      &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;Output&lt;/span&gt; &lt;span class="attr"&gt;TaskParameter&lt;/span&gt;&lt;span class="kwrd"&gt;="Include"&lt;/span&gt; &lt;span class="attr"&gt;ItemName&lt;/span&gt;&lt;span class="kwrd"&gt;="ModuleAssemblies"&lt;/span&gt; &lt;span class="kwrd"&gt;/&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;CreateItem&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;CreateItem&lt;/span&gt; &lt;span class="attr"&gt;Include&lt;/span&gt;&lt;span class="kwrd"&gt;="$(MSBuildProjectDirectory)\$(OutputPath)\*.pdb"&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;      &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;Output&lt;/span&gt; &lt;span class="attr"&gt;TaskParameter&lt;/span&gt;&lt;span class="kwrd"&gt;="Include"&lt;/span&gt; &lt;span class="attr"&gt;ItemName&lt;/span&gt;&lt;span class="kwrd"&gt;="ModuleDebug"&lt;/span&gt; &lt;span class="kwrd"&gt;/&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;CreateItem&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;Copy&lt;/span&gt; &lt;span class="attr"&gt;SourceFiles&lt;/span&gt;&lt;span class="kwrd"&gt;="@(Content)"&lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;          &lt;span class="attr"&gt;DestinationFiles&lt;/span&gt;="@(&lt;span class="attr"&gt;Content&lt;/span&gt; &lt;span class="attr"&gt;-&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt; '$(DNNDirectory)\&lt;/pre&gt;

  &lt;pre class="alt"&gt;                         DesktopModules\$(ModuleFolder)\%(Identity)')" &lt;/pre&gt;

  &lt;pre&gt;          SkipUnchangedFiles="true" &lt;span class="kwrd"&gt;/&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;Copy&lt;/span&gt; &lt;span class="attr"&gt;SourceFiles&lt;/span&gt;&lt;span class="kwrd"&gt;="@(ModuleAssemblies);@(ModuleDebug)"&lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;          &lt;span class="attr"&gt;DestinationFolder&lt;/span&gt;&lt;span class="kwrd"&gt;="$(DNNDirectory)\bin"&lt;/span&gt; &lt;span class="kwrd"&gt;/&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;Copy&lt;/span&gt; &lt;span class="attr"&gt;SourceFiles&lt;/span&gt;&lt;span class="kwrd"&gt;="@(Content)"&lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;          &lt;span class="attr"&gt;DestinationFiles&lt;/span&gt;="@(&lt;span class="attr"&gt;Content&lt;/span&gt; &lt;span class="attr"&gt;-&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt; '$(MSBuildProjectDirectory)\Package\%(Identity)')" SkipUnchangedFiles="true" &lt;span class="kwrd"&gt;/&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;Copy&lt;/span&gt; &lt;span class="attr"&gt;SourceFiles&lt;/span&gt;&lt;span class="kwrd"&gt;="@(ModuleAssemblies);"&lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;          &lt;span class="attr"&gt;DestinationFolder&lt;/span&gt;&lt;span class="kwrd"&gt;="$(MSBuildProjectDirectory)\Package\bin"&lt;/span&gt; &lt;span class="kwrd"&gt;/&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;CreateItem&lt;/span&gt; &lt;span class="attr"&gt;Include&lt;/span&gt;&lt;span class="kwrd"&gt;="$(MSBuildProjectDirectory)\Package\**\*.*"&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;      &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;Output&lt;/span&gt; &lt;span class="attr"&gt;TaskParameter&lt;/span&gt;&lt;span class="kwrd"&gt;="Include"&lt;/span&gt; &lt;span class="attr"&gt;ItemName&lt;/span&gt;&lt;span class="kwrd"&gt;="OutputContent"&lt;/span&gt; &lt;span class="kwrd"&gt;/&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;CreateItem&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;Zip&lt;/span&gt; &lt;span class="attr"&gt;Files&lt;/span&gt;&lt;span class="kwrd"&gt;="@(OutputContent)"&lt;/span&gt; &lt;/pre&gt;

  &lt;pre class="alt"&gt;         &lt;span class="attr"&gt;WorkingDirectory&lt;/span&gt;&lt;span class="kwrd"&gt;="$(MSBuildProjectDirectory)\Package"&lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;         &lt;span class="attr"&gt;ZipFileName&lt;/span&gt;&lt;span class="kwrd"&gt;="$(ProjectName)_$(Major).$(Minor).$(Build)_Install.zip"&lt;/span&gt; &lt;span class="kwrd"&gt;/&gt;&lt;/span&gt;&lt;/pre&gt;

  &lt;pre class="alt"&gt;  &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;Target&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;For formatting I have changed the DNNDirectory, PackageDirectory and ModuleFolder nodes.  Remove the line breaks otherwise you will get an error that says you have illegal characters in the path.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;Now when you build your solution you should get a new folder under DesktopModules that has a ClientBin folder and the js file.  The ClientBin folder should have the .xap file and any associated dlls and pdb files.&lt;/p&gt;

&lt;p&gt;Next we need to add the Usercontrol files to the .Web project so we can register and host the Silverlight application inside DotNetNuke.  Lately i have been using the same Web project to host both the Silverlight Application and the SLTest xap, I add a setting so that i can switch from real to integration test easily.  &lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Add a new User Control to the Web project and call it View.ascx. &lt;/li&gt;

  &lt;li&gt;Add another User Control and call it Settings. &lt;/li&gt;

  &lt;li&gt;Add a reference to the DotNetNuke.dll file. &lt;/li&gt;

  &lt;li&gt;Open up the View.ascx file and paste the following in: 
    &lt;br /&gt;

    &lt;div class="csharpcode"&gt;
      &lt;pre class="alt"&gt;&lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt; &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="text/javascript"&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;    &lt;span class="kwrd"&gt;function&lt;/span&gt; onSilverlightError(sender, args) {&lt;/pre&gt;

      &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;var&lt;/span&gt; appSource = &lt;span class="str"&gt;""&lt;/span&gt;;&lt;/pre&gt;

      &lt;pre&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (sender != &lt;span class="kwrd"&gt;null&lt;/span&gt; &amp;&amp; sender != 0) {&lt;/pre&gt;

      &lt;pre class="alt"&gt;            appSource = sender.getHost().Source;&lt;/pre&gt;

      &lt;pre&gt;        } &lt;span class="kwrd"&gt;var&lt;/span&gt; errorType = args.ErrorType;&lt;/pre&gt;

      &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;var&lt;/span&gt; iErrorCode = args.ErrorCode;&lt;/pre&gt;

      &lt;pre&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (errorType == &lt;span class="str"&gt;"ImageError"&lt;/span&gt; || errorType == &lt;span class="str"&gt;"MediaError"&lt;/span&gt;) {&lt;/pre&gt;

      &lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt;;&lt;/pre&gt;

      &lt;pre&gt;        }&lt;/pre&gt;

      &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;var&lt;/span&gt; errMsg = &lt;span class="str"&gt;"Unhandled Error in Silverlight Application "&lt;/span&gt; + &lt;/pre&gt;

      &lt;pre&gt;        appSource + &lt;span class="str"&gt;"\n"&lt;/span&gt;;&lt;/pre&gt;

      &lt;pre class="alt"&gt;        errMsg += &lt;span class="str"&gt;"Code: "&lt;/span&gt; + iErrorCode + &lt;span class="str"&gt;"    \n"&lt;/span&gt;;&lt;/pre&gt;

      &lt;pre&gt;        errMsg += &lt;span class="str"&gt;"Category: "&lt;/span&gt; + errorType + &lt;span class="str"&gt;"       \n"&lt;/span&gt;;&lt;/pre&gt;

      &lt;pre class="alt"&gt;        errMsg += &lt;span class="str"&gt;"Message: "&lt;/span&gt; + args.ErrorMessage + &lt;span class="str"&gt;"     \n"&lt;/span&gt;;&lt;/pre&gt;

      &lt;pre&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt; (errorType == &lt;span class="str"&gt;"ParserError"&lt;/span&gt;) {&lt;/pre&gt;

      &lt;pre class="alt"&gt;            errMsg += &lt;span class="str"&gt;"File: "&lt;/span&gt; + args.xamlFile + &lt;span class="str"&gt;"     \n"&lt;/span&gt;;&lt;/pre&gt;

      &lt;pre&gt;            errMsg += &lt;span class="str"&gt;"Line: "&lt;/span&gt; + args.lineNumber + &lt;span class="str"&gt;"     \n"&lt;/span&gt;;&lt;/pre&gt;

      &lt;pre class="alt"&gt;            errMsg += &lt;span class="str"&gt;"Position: "&lt;/span&gt; + args.charPosition + &lt;span class="str"&gt;"     \n"&lt;/span&gt;;&lt;/pre&gt;

      &lt;pre&gt;        }&lt;/pre&gt;

      &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;else&lt;/span&gt; &lt;span class="kwrd"&gt;if&lt;/span&gt; (errorType == &lt;span class="str"&gt;"RuntimeError"&lt;/span&gt;) {&lt;/pre&gt;

      &lt;pre&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (args.lineNumber != 0) {&lt;/pre&gt;

      &lt;pre class="alt"&gt;                errMsg += &lt;span class="str"&gt;"Line: "&lt;/span&gt; + args.lineNumber + &lt;span class="str"&gt;"     \n"&lt;/span&gt;;&lt;/pre&gt;

      &lt;pre&gt;                errMsg += &lt;span class="str"&gt;"Position: "&lt;/span&gt; + args.charPosition + &lt;span class="str"&gt;"     \n"&lt;/span&gt;;&lt;/pre&gt;

      &lt;pre class="alt"&gt;            }&lt;/pre&gt;

      &lt;pre&gt;            errMsg += &lt;span class="str"&gt;"MethodName: "&lt;/span&gt; + args.methodName + &lt;span class="str"&gt;"     \n"&lt;/span&gt;;&lt;/pre&gt;

      &lt;pre class="alt"&gt;        }&lt;/pre&gt;

      &lt;pre&gt;        &lt;span class="kwrd"&gt;throw&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt; Error(errMsg);&lt;/pre&gt;

      &lt;pre class="alt"&gt;    }&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;script&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt; &lt;/pre&gt;

      &lt;pre&gt;&lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="silverlightControlHost"&lt;/span&gt; &lt;span class="attr"&gt;style&lt;/span&gt;&lt;span class="kwrd"&gt;="position: relative; &lt;/pre&gt;

      &lt;pre class="alt"&gt;    width: 100%; height: 500px;&lt;/pre&gt;

      &lt;pre&gt;    vertical-align: top; z-index: 50;"&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;object&lt;/span&gt; &lt;span class="attr"&gt;data&lt;/span&gt;&lt;span class="kwrd"&gt;="data:application/x-silverlight-2,"&lt;/span&gt; &lt;/pre&gt;

      &lt;pre&gt;    &lt;span class="attr"&gt;type&lt;/span&gt;&lt;span class="kwrd"&gt;="application/x-silverlight-2"&lt;/span&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;        &lt;span class="attr"&gt;width&lt;/span&gt;&lt;span class="kwrd"&gt;="100%"&lt;/span&gt; &lt;span class="attr"&gt;height&lt;/span&gt;&lt;span class="kwrd"&gt;="100%"&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;        &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;param&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="source"&lt;/span&gt; &lt;span class="attr"&gt;value&lt;/span&gt;&lt;span class="kwrd"&gt;='&lt;%=SilverlightApplication %&gt;'&lt;/span&gt;&lt;span class="kwrd"&gt;/&gt;&lt;/span&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;param&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="onError"&lt;/span&gt; &lt;span class="attr"&gt;value&lt;/span&gt;&lt;span class="kwrd"&gt;="onSilverlightError"&lt;/span&gt; &lt;span class="kwrd"&gt;/&gt;&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;        &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;param&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="background"&lt;/span&gt; &lt;span class="attr"&gt;value&lt;/span&gt;&lt;span class="kwrd"&gt;="Transparent"&lt;/span&gt; &lt;span class="kwrd"&gt;/&gt;&lt;/span&gt;         &lt;/pre&gt;

      &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;param&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="windowless"&lt;/span&gt; &lt;span class="attr"&gt;value&lt;/span&gt;&lt;span class="kwrd"&gt;="true"&lt;/span&gt; &lt;span class="kwrd"&gt;/&gt;&lt;/span&gt; &lt;/pre&gt;

      &lt;pre&gt;        &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;param&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="minRuntimeVersion"&lt;/span&gt; &lt;span class="attr"&gt;value&lt;/span&gt;&lt;span class="kwrd"&gt;="3.0.40624.0"&lt;/span&gt; &lt;span class="kwrd"&gt;/&gt;&lt;/span&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;param&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="autoUpgrade"&lt;/span&gt; &lt;span class="attr"&gt;value&lt;/span&gt;&lt;span class="kwrd"&gt;="true"&lt;/span&gt; &lt;span class="kwrd"&gt;/&gt;&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;        &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;a&lt;/span&gt; &lt;span class="attr"&gt;href&lt;/span&gt;&lt;span class="kwrd"&gt;="http://go.microsoft.com/fwlink/?LinkID=149156&amp;v=3.0.40624.0"&lt;/span&gt; &lt;span class="attr"&gt;style&lt;/span&gt;&lt;span class="kwrd"&gt;="text-decoration: none"&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;            &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;img&lt;/span&gt; &lt;span class="attr"&gt;src&lt;/span&gt;&lt;span class="kwrd"&gt;="http://go.microsoft.com/fwlink/?LinkId=108181"&lt;/span&gt; &lt;span class="attr"&gt;alt&lt;/span&gt;&lt;span class="kwrd"&gt;="Get Microsoft Silverlight"&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;                &lt;span class="attr"&gt;style&lt;/span&gt;&lt;span class="kwrd"&gt;="border-style: none"&lt;/span&gt; &lt;span class="kwrd"&gt;/&gt;&lt;/span&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;        &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;a&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;    &lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;object&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

      &lt;pre class="alt"&gt;    &lt;span class="kwrd"&gt;&lt;&lt;/span&gt;&lt;span class="html"&gt;iframe&lt;/span&gt; &lt;span class="attr"&gt;id&lt;/span&gt;&lt;span class="kwrd"&gt;="_sl_historyFrame"&lt;/span&gt; &lt;span class="attr"&gt;style&lt;/span&gt;&lt;span class="kwrd"&gt;="visibility: &lt;/pre&gt;

      &lt;pre&gt;        hidden; height: 0px; width: 0px;&lt;/pre&gt;

      &lt;pre class="alt"&gt;        border: 0px"&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;iframe&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="kwrd"&gt;&lt;/&lt;/span&gt;&lt;span class="html"&gt;div&lt;/span&gt;&lt;span class="kwrd"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;
    &lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/li&gt;

  &lt;li&gt;Open up the code behind file and modify it to look like this. 
    &lt;br /&gt;

    &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;partial&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; View : PortalModuleBase
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; SilverlightApplication { get; set; }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; SilverlightInitParams { get; set; }
    &lt;span class="kwrd"&gt;protected&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Page_Load(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)
    {
        &lt;span class="kwrd"&gt;bool&lt;/span&gt; isChecked;
        var xapFile = &lt;span class="str"&gt;"MySilverlightApplication.xap"&lt;/span&gt;;
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;bool&lt;/span&gt;.TryParse(Settings[&lt;span class="str"&gt;"IsTest"&lt;/span&gt;].ToString(), &lt;span class="kwrd"&gt;out&lt;/span&gt; isChecked))
        {
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (isChecked)
                xapFile = &lt;span class="str"&gt;"MySilverlightApplication.SLTest.xap"&lt;/span&gt;;
        }
        &lt;span class="rem"&gt;// Register Silverlight.js file            &lt;/span&gt;
        Page.ClientScript.RegisterClientScriptInclude(&lt;span class="kwrd"&gt;this&lt;/span&gt;.GetType(), 
            &lt;span class="str"&gt;"SilverlightJS"&lt;/span&gt;, (String.Format(&lt;span class="str"&gt;@"{0}{1}"&lt;/span&gt;, 
            TemplateSourceDirectory, &lt;span class="str"&gt;"/Silverlight.js"&lt;/span&gt;)));
        &lt;span class="rem"&gt;// Set the path to the .xap file   &lt;/span&gt;
        SilverlightApplication = String.Format(&lt;span class="str"&gt;"{0}/ClientBin/{1}"&lt;/span&gt;, 
            TemplateSourceDirectory, xapFile);
        &lt;span class="rem"&gt;// Pass the Initialization Parameters to the Silverlight Control            &lt;/span&gt;
        SilverlightInitParams = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;"Test={0}"&lt;/span&gt;, &lt;span class="str"&gt;"Some init stuff"&lt;/span&gt;);
    }
}&lt;/pre&gt;
    &lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/li&gt;

  &lt;li&gt;In the settings file add a check box and save its value as a setting and call the setting “IsTest”. &lt;/li&gt;

  &lt;li&gt;Now build you solution. &lt;/li&gt;

  &lt;li&gt;You are now ready to register your module with DotNetNuke so go ahead and do that. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That’s it for Part 1.  You are now set up ready to start developing, designing and testing your application.  &lt;/p&gt;</description>
      <link>http://www.philipbeadle.net/Home/tabid/252/EntryId/617/How-to-build-a-fully-Blendable-and-Testable-Silverlight-RIA-Services-DNN-Module-ndash-Part-1-Setting-up.aspx</link>
      <comments>http://www.philipbeadle.net/Home/tabid/252/EntryId/617/How-to-build-a-fully-Blendable-and-Testable-Silverlight-RIA-Services-DNN-Module-ndash-Part-1-Setting-up.aspx#Comments</comments>
      <guid isPermaLink="true">http://www.philipbeadle.net/Home/tabid/252/EntryId/617/How-to-build-a-fully-Blendable-and-Testable-Silverlight-RIA-Services-DNN-Module-ndash-Part-1-Setting-up.aspx</guid>
      <pubDate>Thu, 24 Sep 2009 03:21:17 GMT</pubDate>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://philipbeadle.net/DesktopModules/Blog/Trackback.aspx?id=617</trackback:ping>
    </item>
    <item>
      <title>Just got back from Tech Ed Aus 2009</title>
      <description>&lt;p&gt;Last week I attended Tech Ed Australia for the 5th time in a row and what a great time was had by all.  I did plenty of networking (really means beer drinking with delegates) and attended a bunch of cool sessions and I even delivered a lunch time session on my fave topics, DotNetNuke, Silverlight and RIA Services.  &lt;/p&gt;  &lt;p&gt;I went to a bunch of Silverlight/UX sessions by &lt;a href="http://blogs.msdn.com/shanemo/" target="_blank"&gt;Shane Morris&lt;/a&gt; (Microsoft) which were excellent and really brought home to me how much room for improvement there is the application/site design UX space.  So Im really going to be pushing some of his recommendations and finding ways to convince clients that there are better ways they just have to trust me :)&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blog.webjak.net" target="_blank"&gt;Jordan&lt;/a&gt; and Mahesh who both work with me at &lt;a href="http://www.readify.net" target="_blank"&gt;Readify&lt;/a&gt; gave an excellent session  on architectural considerations when building Silverlight applications and Jordan also had a going deeper with Silverlight session that I can’t wait to get my hands on the code from.&lt;/p&gt;  &lt;p&gt;I also went to see &lt;a href="http://www.soulsolutions.com.au/" target="_blank"&gt;John and Bronwen from Soul Solutions&lt;/a&gt; do a session on spatial data and the Bing Maps Control.  That was an eye opener.  I had heard about spatial in SQL 2008 but had never used it, now I’m going to use it on my current project to display some mined data.&lt;/p&gt;  &lt;p&gt;Thanx everyone who I met and caught up with it was a great time.&lt;/p&gt;</description>
      <link>http://www.philipbeadle.net/Home/tabid/252/EntryId/616/Just-got-back-from-Tech-Ed-Aus-2009.aspx</link>
      <comments>http://www.philipbeadle.net/Home/tabid/252/EntryId/616/Just-got-back-from-Tech-Ed-Aus-2009.aspx#Comments</comments>
      <guid isPermaLink="true">http://www.philipbeadle.net/Home/tabid/252/EntryId/616/Just-got-back-from-Tech-Ed-Aus-2009.aspx</guid>
      <pubDate>Tue, 15 Sep 2009 21:07:13 GMT</pubDate>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://philipbeadle.net/DesktopModules/Blog/Trackback.aspx?id=616</trackback:ping>
    </item>
  </channel>
</rss>