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

Building a Better ASP.NET 1.1 BasePage Framework

Rate me:
Please Sign up or sign in to vote.
4.52/5 (27 votes)
5 Dec 2005CPOL35 min read 124.9K   2.1K   156  
This is a journey on how to build a better Base page. The result of this will be a reusable framework that you can use to create as many Base pages as you like (on many different sites) and still have something that will keep the designers on your team happy.
using System;

namespace AcmeWidgets.Base
{
	/// <summary>
	/// Summary description for AcmeBasePage.
	/// </summary>
	public class AcmeBasePage : BasePageFramework.SuperBasePage
	{
		
		private AcmeControls.LeftNav _leftNav = null;

		protected override void LoadBaseUITemplate(ref BasePageFramework.IBaseTemplate tmplt)
		{
			tmplt = (BasePageFramework.IBaseTemplate)LoadControl("~/Base/AcmeBaseTemplate.ascx");
		}

		protected override void LoadTemplatePanels()
		{
			_leftNav = (AcmeControls.LeftNav)LoadControl("~/AcmeControls/LeftNav.ascx");
			((AcmeBaseTemplate)this.MainUITemplate).LeftNavigation.Controls.Add(_leftNav);
			_leftNav.OnNavClick += new AcmeWidgets.AcmeControls.LeftNavEvent(_leftNav_OnNavClick);
		
		}

		protected override void InitializeConfiguration(ref BasePageFramework.Configuration.ConfigLoadingArgs configParams)
		{
			configParams.BasePageID = "AcmeBase";
		}
		protected override void InitSmartQueryString(ref BasePageFramework.SmartState.ISmartQueryString isqs)
		{
			isqs = (BasePageFramework.SmartState.ISmartQueryString)new AcmeSmartState.AcmeSmartQueryString();
		}
		protected override void InitSmartSession(ref BasePageFramework.SmartState.ISmartSession ises)
		{
			ises = (BasePageFramework.SmartState.ISmartSession)new AcmeSmartState.AcmeSmartSession();
		}

		private void _leftNav_OnNavClick(object sender, AcmeWidgets.AcmeControls.LeftNavEventArg e)
		{
			switch(e.PageNumber)
			{
				case "1":
					this.SmartQueryString.SmartRedirect("Default.aspx");
					break;
				case "2":
					this.SmartQueryString.SmartRedirect("PageTwo.aspx");
					break;
				case "3":
					this.SmartQueryString.SmartRedirect("PageThree.aspx");
					break;
				case "4":
					this.SmartQueryString.SmartRedirect("PageFour.aspx");
					break;
				default:
					this.SmartQueryString.SmartRedirect("Default.aspx");
					break;
			}
		}
	}
}

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) Priority Courier Experts
United States United States
software developer for about 25 years now.

Comments and Discussions