Click here to Skip to main content
15,893,588 members
Articles / Web Development / ASP.NET

Model View Presenter via ASP.NET

Rate me:
Please Sign up or sign in to vote.
4.38/5 (10 votes)
11 Oct 2009CPOL6 min read 39.4K   291   24  
Following on from articles on adding generics support to ASP.NET, how to pass through arbitrary types to data sources, and implementing MVP in a type safe fashion, today Steve Gray takes readers through how to implement the various elements of a modular, re-usable MVP framework for ASP.NET.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using CobaltSoftware.Foundation.ModelViewPresenter;

namespace CobaltSoftware.Foundation.Web.Patterns.ModelViewPresenter
{
    /// <summary>
    ///     The IPresenterLoader interface provides mechanisms for obtaining
    ///     presenters. Various implementations may use inversion of control or
    ///     other mechanisms in order to supply the presenter instances at
    ///     runtime.
    /// </summary>
    /// <remarks>
    ///     <para>
    ///         <list>
    ///             <listheader>Version History</listheader>
    ///             <item>11 October, 2009 - Steve Gray - Initial Draft</item>
    ///         </list>
    ///     </para>
    /// </remarks>
    public interface IPresenterLoader
    {        
        /// <summary>
        ///     Load the appropriate view.
        /// </summary>
        /// <param name="owner">Owning control (Orchestrator)</param>
        /// <typeparam name="TPresenterContract">Presenter contract type</typeparam>
        /// <typeparam name="TViewContract">View contract type</typeparam>
        /// <returns>Presenter instance</returns>
        TPresenterContract GetPresenterInstance<TPresenterContract, TViewContract>(Control owner)
            where TPresenterContract : IPresenter<TPresenterContract, TViewContract>
            where TViewContract : IView<TViewContract, TPresenterContract>;
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Insurance Industry
United Kingdom United Kingdom
Steve Gray is a Senior Developer at a British insurance company, working on a popular aggregator. When he's not writing ASP .NET, it's because there's SQL or WCF to write instead.

Comments and Discussions