Custom Search

Master Pages

This section will guide a new user of how to setup a master page for their project. A Master Page allows you to retain consistent content throughout your website. An advantage of this is having a single place where one change can reflect on all of the other pages. It prevents having to create repetitive layout designs.

Master Pages Video Tutorial

If you want to save some reading then you are welcome instead to watch this video.However the content was created since others claim the video didn't fulfill every need.

Learn C# today

If you are also looking for a great C# book then I would like to personally recommend Visual C# 2010. It may seem a little dated, but there is a wealth of information inside. I used this book to obtain my first position as a Software Developer. Just click on the link below to check it out. You will soon be learning more advanced techniques that will better help you in your career goals. It provides an excellent insight to object oriented design as well and has great visual examples.

It also provides step by step tutorials for the beginner up to the advanced user. There are some great concepts to learn about what happens during a page refresh that are packed inside and it will answer questions such as what are the common keywords used in Object Oriented code - answer public, private, and protected. There is a great wealth of information about setting up your own class objects and using them in your programs.

It will teach you how to write your own condition statement (used for allowing the computer to make decisions), how arrays work, capturing error messages (using exceptions), using Generics (advanced), creating collection enumerations, and using LINQ to write simple query expressions.

Chapters 22 and beyond are devoted to Windows Presentation Foundation (WCF), Databases (using SQL)m and Web Services. So there is a lot of information contained within it's 748 pages with 29 Chapters. Most orders will come with a CD so you don't have to type in the programs yourself.

So I highly recommend it. Once again this book helped increase my understanding of C#, which eventually led to my first job in Information Technology. If you want to further your career then I encourage you to act for your future today!

Step 1: Create a new Web Application

In Visual Studio select File - New - Project. In the Name field you will name the web page. This example's name is MyFirstWebSite.

master page

If you click on the Design button you will see the Master page as shown below.

master page

Remember that this page has a ContentPlaceHolderID named HeadContent and MainContent.

master page

Next open the Site.master page and click on the Sourcebutton. Observe that this page also has a ContentPlaceHolder with a name of HeadContent. This page also has a reference to the Site.master on the label MasterPageFile.The Content ID is a control that links the master page to your web page (Default.aspx). Later you will embed html code inside that will be seen on all pages.

master page

Step 2: Add a second page to the site

In Visual Studio select File - New - Project. In this example I called it WebPage2.aspx and again you are free to select your own name.

master page

Step 3: Remove the html tags.

Change the content on this page so it looks like the below screenshot.The goal is to remove all of the title, head, body, form tags. Then you will embed your own asp controls and html code inside of the div tags as seen in this example.If some reason this screenshot is too small or unclear here is the text for this page.

<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Site.master" CodeFile="WebPage2.aspx.cs" Inherits="WebPage2" %>

My Test Page

master page

Now in Solution Explorer right click on the page called WebPage2.aspx and select Set As Start Page. If everything was succesful you will also notice that this page uses the same Master page content.So everything you now change in the Site1.Master will be reflected on the Default and WebPage2.aspx pages. When you add future pages make sure to duplicate the code in WebPage2.aspx and add the html content to your liking.

master page

Apply to be a Chitika Publisher!
Subscribe to the my newsletter
Privacy Notice: Programmer Mind will not compromise your privacy