Click here to Skip to main content
15,895,798 members
Articles / Web Development / IIS

An Extensible Master-Page Framework for ASP.NET 1.1 Using Pattern Oriented Design

Rate me:
Please Sign up or sign in to vote.
4.90/5 (95 votes)
30 Jun 20049 min read 353.9K   6.5K   245  
Development of a framework for master-pages using ASP.NET and C#.
#region (C) Shams Mukhtar
//
// All rights are reserved. Reproduction or transmission in whole or in part, in
// any form or by any means, electronic, mechanical or otherwise, is prohibited
// without the prior written permission of the copyright owner.
//
// Filename: PageUserControl.ascx.cs
#endregion

#region Instructions
// Here�s the command to create the library DLL:
// csc /t:library PageUserControl.ascx.cs
// you should place the DLL in wwwroot/bin.
#endregion

#region Remarks
// The UserControl class is associated with files that have .ascx extensions. 
// These files are compiled at run time as UserControl objects and cached in server memory.
// You can nest user controls by declaring one .ascx file in another including the latter in a Web Forms page.
// User controls are contained in ASP.NET Web Forms pages, and offer Web developers an easy way to capture 
// commonly used Web UI. They are instantiated and cached in ways similar to Page objects. Unlike pages, 
// however, user controls cannot be called independently. They can only be called from the page or other 
// user control that contains them. 
// Derive from this class if you want to create a user control using the code-behind technique. 
// This is recommended if you are developing Web Forms pages using this technique.
#endregion

#region Included NameSpaces
	using System;
	using System.Data;
	using System.Drawing;
	using System.Web;
	using System.Web.UI.WebControls;
	using System.Web.UI.HtmlControls;
#endregion

namespace Shams.Web.UI.MasterPages
{
	/// <summary>
	/// Abstract Base for All Page UserControls
	/// </summary>
	public abstract class PageUserControlBase : System.Web.UI.UserControl, IPageControlAttributes
	{
		protected System.Web.UI.WebControls.PlaceHolder placeHolderLogo;
		protected System.Web.UI.WebControls.PlaceHolder placeHolderHeader;
		protected System.Web.UI.WebControls.PlaceHolder placeHolderMenu;
		protected System.Web.UI.WebControls.PlaceHolder placeHolderSubMenu;
		protected System.Web.UI.WebControls.PlaceHolder placeHolderContents;
		protected System.Web.UI.WebControls.PlaceHolder placeHolderFooter;
		protected System.Web.UI.WebControls.PlaceHolder placeHolderNavigation;
		protected System.Web.UI.WebControls.PlaceHolder placeHolderSiteCounter;
		protected System.Web.UI.WebControls.Panel panelMain;
		protected System.Web.UI.WebControls.Image Image2;
		protected System.Web.UI.WebControls.Image ImageHeader;
		protected System.Web.UI.WebControls.Image Image3;
		protected System.Web.UI.WebControls.Image Image4;
		protected System.Web.UI.WebControls.Image Image5;
		protected System.Web.UI.WebControls.Image Image1;
		protected System.Web.UI.WebControls.Image Image6;
		protected System.Web.UI.WebControls.Image Image7;
		protected System.Web.UI.WebControls.Panel panelNavigator;

		public PageUserControlBase()
		{
			InitializeComponents();
		}

		private void InitializeComponents()
		{
			panelMain = new Panel();

			panelNavigator = new Panel();
			placeHolderLogo		= new PlaceHolder();
			placeHolderHeader	= new PlaceHolder();
			placeHolderMenu		= new PlaceHolder();
			placeHolderSubMenu	= new PlaceHolder();
			placeHolderContents = new PlaceHolder();
			placeHolderFooter	= new PlaceHolder();
			placeHolderNavigation = new PlaceHolder();
			placeHolderSiteCounter= new PlaceHolder();
		}

		private void InitializeComponent()
		{
		
		}

		public System.Web.UI.Control ParentControl()
		{
			return this;
		}

		public Panel PanelMain
		{
			get
			{
				return panelMain;
			}
		}
		
		public Panel PanelNavigator
		{
			get
			{
				return panelNavigator;
			}
		}
		public PlaceHolder PlaceHolderHeader
		{
			get
			{
				return placeHolderHeader;
			}		
		}

		public PlaceHolder PlaceHolderLogo
		{
			get
			{
				return placeHolderLogo;
			}
		}
		public PlaceHolder PlaceHolderMenu
		{
			get
			{
				return placeHolderMenu;
			}
		}
		public PlaceHolder PlaceHolderSubMenu
		{
			get
			{
				return placeHolderSubMenu;
			}
		}
		public PlaceHolder PlaceHolderNavigation
		{
			get
			{
				return placeHolderNavigation;
			}
		}
		public PlaceHolder PlaceHolderContents
		{
			get
			{
				return placeHolderContents;
			}
		}
		public PlaceHolder PlaceHolderFooter
		{
			get
			{
				return placeHolderFooter;
			}
		}
		public PlaceHolder PlaceHolderSiteCounter
		{
			get
			{
				return placeHolderSiteCounter;
			}
		}
	}

	/// <summary>
	///	Summary description for PageUserControl.
	/// </summary>
	public class PageUserControl : PageUserControlBase
	{
		private void Page_Load(object sender, System.EventArgs e)
		{
			// Put user code to initialize the page here
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		///		Required method for Designer support - do not modify
		///		the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Chief Technology Officer GeeksCafe.NET | Infortran.COM
United States United States
Lead Architect with 20+ years of software design and development experience. Architected and designed many industrial softwares and passed through full software development life-cycle. Strong hold in Object-Oriented software engineering using UML with Design Patterns, C#, .NET, C++/VC++ and Java. Domain expertise are in Distributed Computing along with WCF/Web services, Messaging Systems (MSMQ), Multi-threading, Component developments, Computer Graphics, Embedded Systems, GIS development, framework development, User-Interface designs (WPF .NET), Rule based development (WF .NET), Chemical Engineering and Process Controls. Having both Bachelors and Masters degrees in Engineering with certifications in Obect Oriented Analysis and design. Smile | :)

Email: shams.mukhtar@gmail.com
Blog Link: http://www.geekscafe.net


Comments and Discussions