Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

Best Practices: Headers/Footers on Web Forms

We are beginning to experiment with ASP.NET for porting some of our creaky old internal VB/Access legacy utilities to web applications for use on our company WAN/LAN, and I am interested to know what other people are doing to create a consistent "look and feel" between various web forms from the same application.

One thing that my manager really wants to see is recurring headers and/or footers at the top and bottom of all our internal forms.  Typically, the header would contain things like  the date & time, application title, form title, retail store location code, and maybe a company logo, etc.  The footer might contain things like the user name, computer name, domain, etc.  We might also want recurring buttons for functions like logging out, help, etc...

One of the reasons we want this information on every screen is in the event that users take screen shots to ask questions/report bugs and forget to tell us vital "when, where, who" types of things.

Any thoughts on what the most ".NET way" of accomplishing this type of thing would be?

Also, is it possible to "anchor" headers and footers to the top and bottom of a web form so that they would grow/shrink with various browser sizes?

Examples/Links would be GREATLY appreciated!

Tim Lara
Wednesday, December 10, 2003

Look into UserControls [1]

These basically allow you to create reusable UI 'chunks' (in this case header and footer) that you can place at the top and bottom of all your pages.

The output html can also be cached providing a perf gain.


Rick Childress
Wednesday, December 10, 2003

Google for "ASP.NET MasterPages". You'll definitely want to use them after Whidbey (ASP.NET 2.0; due next year) launches, and there are some ASP.NET 1.0/1.1 versions in various corners of the net.

Dave Rothgery
Thursday, December 11, 2003

Thanks, guys.

Always nice to have a "heads up" on the new stuff.  I wish I had started tinkering with .NET a couple of years ago.  Sure would have saved me a lot of time right now!

Tim Lara
Thursday, December 11, 2003

MasterPages is the way to go. Also see: (Paul Wilson's Controls) for Template-driven pages.

Friday, December 12, 2003

MasterPages are nice but .NET 1.1 introduced a major bug that can make life with them difficult if you try to use any generated JavaScript with them. 

For example, if you have a DataGrid control on your page that uses the built-in sorting capabilities, it won't work in a MasterPage style system because the sort headers are link buttons that postback using JavaScript. 

An easy way to tell if an existing page will be affected by this is to browse to the page, view source, then search for "__doPostBack".  ASP.NET will only output the code for __doPostBack if you have something on the page that depends on it, and if you have something that depends on it, it'll break in a MasterPage with ASP.NET 1.1.

Microsoft has a fix for this but it's only available if you ask for it.  Not a big deal if you have your own servers but if you use a hosting plan, it adds the major hassles of trying to determine if they have the fix installed and trying to get them to install the fix.  There are also some 3rd party hacks out there to fix this but they're pretty nasty. 

The official story is here:;en-us;818803

Friday, December 12, 2003

Problems with forms in user controls in ASP.NET 1.1 will not have a bearing on Master Pages in ASP.NET 2.0.

In the meantime, you could look at using an HttpModule (get to modify the Response before it goes to the client, so you could insert your headers and footers there, although it might involve some slightly nasty string substitution).

Kevin Daly
Friday, January 23, 2004

My two cents.
Module from module fixes .NET 1.1 form postback problem

Wednesday, March 10, 2004

*  Recent Topics

*  Fog Creek Home