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

Page Template Framework for ASP.NET 1.1

Rate me:
Please Sign up or sign in to vote.
4.64/5 (63 votes)
16 Nov 20048 min read 298.3K   5.3K   168  
The Page Template Framework for ASP.NET 1.1 provides a configurable solution for creating page templates in a Web application. Using this framework, page templates are stored in an XML file, and can be dynamically configured without recompiling the Web application.
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Boardworks.Web.UI.PageFramework;
using Boardworks.Web.UI.PageFramework.Config;

namespace PageTemplateSample
{
	/// <summary>
	/// The Default Web Form for the application, which inherits
	/// from the Page Template Framework PageBase
	/// </summary>
	public class _Default : Boardworks.Web.UI.PageFramework.PageBase
	{
		/// <summary>
		/// Used to display the current Page's title
		/// </summary>
		protected System.Web.UI.WebControls.Label lblContentTitle;

		/// <summary>
		/// Method called when the Page is loaded for the current Request
		/// </summary>
		/// <param name="sender">The current Page instance (i.e. ASP.Default_aspx)</param>
		/// <param name="e">The event's arguments</param>
		private void Page_Load(object sender, System.EventArgs e)
		{
			//
			// If this page is being viewed under the DivisionTemplate, then
			// programatically change the way the GeneralNavigation is displayed
			//

			// Load the current Page.config file into an instance of the PageConfig class
			PageConfig pc = PageConfig.Load(Server.MapPath(PageConfig.PageConfigFilePath));

			// Find the current requested Page in the Page.config file
			Boardworks.Web.UI.PageFramework.Config.Page page = pc.FindPage(this.Request);

			// Check to ensure this page is registered with the Page.config file
			if (page != null)
			{
				// Check to see if this page's current Template is DivisionTemplate
				if (page.TemplateName == "DivisionTemplate")
				{
					// Find the General Navigation Control by it's UniqueName attribute
					PageTemplateSample.Controls.General.Navigation nav = (PageTemplateSample.Controls.General.Navigation)this.FindControl("GeneralNavigation");

					// Change the LineBreak to a Pipe symbol for the Navigation
					nav.cLineBreak1.Text = nav.cLineBreak2.Text = nav.cLineBreak3.Text = "|";
				}
			}
		}

		#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
Web Developer
United States United States
Scott Van Vliet is a Principal Consultant with Neudesic based in Irvine, CA. He has been designing and developing technology solutions for the past 8 years, and has worked with Microsoft .NET technologies for over 3 years. Scott is currently developing solutions with ASP.NET 2.0, C# 2.0, Windows Presentation Foundation (codename "Avalon"), SQL Server 2000/2005, Reporting Services and SharePoint.

Scott welcomes feedback and can be reached through his Weblog at http://weblogs.asp.net/skillet/.

Comments and Discussions