Working with ASP.NET Master Pages

by Nate on August 12, 2006


So, I’ve been working a lot with ASP.NET 2.0 while building the Naldara Geomatics website. I knew from the beginning that I wanted to use CSS, as I am all for making the design and management of websites easier (and I really don’t like how tables look or act). As I started work on the site, though, I ran into a new feature of ASP.NET 2.0 – master pages.

I’m not going to really delve into what master pages are; there are hundreds of websites and blog posts that already cover this, and they all say basically the same things (if you don’t believe me, try a google search for “asp master pages”. Here are the basics: master pages allow you to create a template page, with CSS, menus, headers and footers, images, etc. and create what are called content placeholders within the page. You can then create pages using the master page as the template, and only worry about creating content for the sections that are unique to the particular page. The strength of this should be obvious: if you have a single template master page, you only have to edit a single HTML page when changes to a menu or logo or footer are needed. And, of course, you don’t have to worry about adding scripts multiple times to multiple pages (and then you don’t have to worry about keeping them all in sync and clean).

Not being very experienced in the use of ASP.NET or master pages, I don’t want to assert that I know everything there is to know about the two. However, I have noticed that the use of master pages makes it much more difficult to get ASP applications to work. Notice I didn’t say that it doesn’t work. There simply isn’t, at this point, enough online documentation or help available.

For example, I have been working on putting together an ASP contact form that utilizes several controls and sits within a master page template. When the controls sit inside of a content placeholder, I have not yet been able to get it to work well. For some reason, a control that sits inside of a content placeholder has the unique (and this is important) name of the content placeholder and and another (logical, I’m sure, but unknown to me) set of alphanumeric characters appended to the front of its name. So, to access a control’s input, you have to first find out what this unique name is and then call it into whatever script you are using. There has to be a better way of doing this, but I haven’t figured it out.

Anyways, enough for now. Once I solve this problem, I’ll update the post to reflect what I have learned. If any kind souls out there want to help, please do!

Leave a Comment

Previous post:

Next post: