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

Open Source Extensible Enterprise n-tier Application Framework with Multilayered Architecture

Rate me:
Please Sign up or sign in to vote.
4.67/5 (2 votes)
3 Dec 2010MIT3 min read 36.9K   770   41  
Xenta architecture overview
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Web.UI.WebControls;
using SiberTek.Xenta.Presentation.Presenters;
using SiberTek.Xenta.Presentation.Views;
using SiberTek.Xenta.Web.Controls;

namespace SiberTek.Xenta.Web.Forum.Modules
{
    public partial class ForumDropDownList : ViewBase<ForumPresenter>, IDropDownList<Int32?>
    {
        #region Events
        public event EventHandler SelectedIndexChanged;
        #endregion

        #region Properties
        public int? ParentForumID
        {
            get
            {
                return null;
            }
        }

        public bool AutoPostBack
        {
            get
            {
                return lstForumList.AutoPostBack;
            }
            set
            {
                lstForumList.AutoPostBack = value;
            }
        }

        public bool AllowEmptyItem
        {
            get
            {
                return Convert.ToBoolean(ViewState["AllowEmptyItem"]);
            }
            set
            {
                ViewState["AllowEmptyItem"] = value;
            }
        }

        [Browsable(false)]
        public int? SelectedValue
        {
            get
            {
                return String.IsNullOrEmpty(lstForumList.SelectedValue) ? (int?)null : Int32.Parse(lstForumList.SelectedValue);
            }
            set
            {
                lstForumList.SelectedValue = value.HasValue ? value.Value.ToString() : String.Empty;
            }
        }

        public int ItemCount
        {
            get
            {
                return lstForumList.Items.Count;
            }
        }

        public bool Enabled
        {
            set
            {
                lstForumList.Enabled = value;
            }
        }
        #endregion

        #region Methods
        public override void BindData()
        {
            DataContainer["ShowHidden"] = false;
            DataContainer["ParentForumID"] = ParentForumID;

            Presenter.LoadCollection();

            lstForumList.Items.Clear();

            List<ViewDataContainer> itemCollection = DataContainer["ForumCollection"] as List<ViewDataContainer>;

            if(AllowEmptyItem)
            {
                lstForumList.Items.Add(new ListItem("-", String.Empty));
            }
            foreach(ViewDataContainer item in itemCollection)
            {
                lstForumList.Items.Add(new ListItem((string)item["Title"], item["ForumID"].ToString()));
            }

            base.BindData();
        }
        #endregion

        #region Handlers
        protected void LstForumList_OnSelectedIndexChanged(object sender, EventArgs e)
        {
            FireSelectedIndexChangedEvent();
        }
        #endregion

        #region Utilities
        private void FireSelectedIndexChangedEvent()
        {
            if(SelectedIndexChanged != null)
            {
                SelectedIndexChanged(this, EventArgs.Empty);
            }
        }
        #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 MIT License


Written By
Russian Federation Russian Federation
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions