• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 903
  • Last Modified:

Master page and default.aspx

Hey Experts,
I've spent some time working with C# but just now starting to learn about ASP.NET and VS2005 so sorry about such a noob question.

How do I make the default.aspx a content page for my master page ? I already have a master page created. I need my site to start with my masterPage and default.aspx be its content.

Thanks in advance.
2 Solutions
In the @Page directive of your default.aspx, add the following attribute, replacing "MyMaster.master" with the name of your master page. Your default.aspx file then needs to get rid of the html, head, and body tags and should only have an asp:content control that points to the content area of the master page:


The easier way to do this depends on if you are using a Website project or a Web Application project. If you are using a website project, right click on the project in solution explorer in visual studio and select add new item and then choose "Web Form" from the list and there is a checkbox at the bottom that says something like "Select Master page" which will pop up the master page selection screen after you click next/finish. If you are using a web application project, right-click on the project in solution explorer and go to add new item again. This time, instead of web form, select "web content form" and this will allow you to see the master page selection screen when you click next/finish.
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
    CodeFile="default.aspx.cs" Inherits="default" Title="Untitled Page" %>

add this code into ur default page
techsuppoprtAuthor Commented:
Thanks guys!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now