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

Advancing the Model-View-Presenter Pattern - Fixing the Common Problems

Rate me:
Please Sign up or sign in to vote.
4.53/5 (28 votes)
6 Sep 2007CPOL7 min read 186.6K   611   105  
Addressing the common issues related to the MVP pattern using ASP.NET and WinForms clients.
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Sample.Presentation;

[PresenterType(typeof(AlternatePresenter))]
public partial class Alternate : BasePage, IAlternateView
{

    protected void Page_Load( object sender, EventArgs e )
    {
        base.SelfRegister(this);

        if(!Page.IsPostBack)
        {
            if (OnLoadView != null)
            {
                this.OnLoadView();
            }
        }
    }

    protected void monthList_SelectedIndexChanged( object sender, EventArgs e )
    {
        if (this.OnMonthChanged != null)
        {
            this.OnMonthChanged();
        }
    }

    protected void dayList_SelectedIndexChanged( object sender, EventArgs e )
    {
       
    }

    #region IDefaultPageView Members
    public event EmptyEventHandlerDelegate OnLoadView;

    void IDefaultPageView.AddWeekday( string day )
    {
        weekdayPanel.Visible = true;
        weekdayLabel.Text = day;
    }

    void IDefaultPageView.AddMonth( string month )
    {
        monthList.Items.Add(month);
        dayList.Items.Clear();
    }

    #endregion

    #region IAlternateView Members
    void IAlternateView.AddDayNumber( string day )
    {
        dayPanel.Visible = true;
        dayList.Items.Add(day);
    }

    int IAlternateView.SelectedMonth
    {
        get { return monthList.SelectedIndex + 1; }
    }

    string IAlternateView.UserName
    {
        set { this.userNameLabel.Text = value; }
    }

    public event EmptyEventHandlerDelegate OnMonthChanged;
    #endregion
}

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
Web Developer PageLabs
United States United States
I'm the founder of PageLabs, a web-based performance and SEO optimization site.

Give your site a boost in performance, even take a free speed test!

http://www.pagelabs.com

Comments and Discussions