• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 902
  • 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!

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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