Created
October 20, 2009 17:21
-
-
Save orjan/214437 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Web.UI; | |
namespace WebApplication.template | |
{ | |
public class BasePage : Page | |
{ | |
public BasePage() | |
{ | |
HeaderControls = new ControlCollection(this); | |
FooterControls = new ControlCollection(this); | |
} | |
protected ControlCollection FooterControls { get; set; } | |
protected ControlCollection HeaderControls { get; set; } | |
protected override void OnInit(EventArgs e) | |
{ | |
base.OnInit(e); | |
HeaderControls.Add(LoadControl("controls/header.ascx")); | |
FooterControls.Add(LoadControl("controls/footer.ascx")); | |
} | |
protected override void Render(HtmlTextWriter writer) | |
{ | |
RenderTemplate(HeaderControls, writer); | |
base.Render(writer); | |
RenderTemplate(FooterControls, writer); | |
} | |
private static void RenderTemplate(ControlCollection collection, HtmlTextWriter writer) | |
{ | |
foreach (Control c in collection) | |
{ | |
c.RenderControl(writer); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment