Click here to Skip to main content
Click here to Skip to main content
Articles » Web Development » ASP.NET » General » Downloads
 
Add your own
alternative version

Presentation Model and Dependency Injection

By , 26 Apr 2009
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Web.UI.WebControls;
using Demo.DataModel;
using Demo.Web.Mvvm;

namespace Demo.WebApp
{
    public partial class CustomerList : System.Web.UI.UserControl
    {
        public bool UsePopup { get; set; }

        [Inject]
        public ICustomerList controller { get; set;}

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

        [EventSubscription]
        void OnCustomerListChanged(object sender, EventArgs e)
        {
            try
            {
                CustomerGridView.DataBind();
            }
            catch (Exception ex)
            {
                ErrorHandler.HandleException(this, ex);
            }            
        }

        protected void CustomerListDataSource_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
        {
            e.ObjectInstance = controller;
        }

        protected void CustomerGridView_SelectedIndexChanged(object sender, EventArgs e)
        {
            controller.SelectCustomer(CustomerGridView.SelectedDataKey.Value.ToString());
        }

        protected void btnNew_Click(object sender, EventArgs e)
        {
            controller.NewCustomer();
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of use 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 Microsoft Public License (Ms-PL)

About the Author

Yiyi Sun
Architect
Canada Canada
No Biography provided

| Advertise | Privacy | Mobile
Web03 | 2.8.140415.2 | Last Updated 26 Apr 2009
Article Copyright 2009 by Yiyi Sun
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid