Master page and default.aspx

Posted on 2007-07-23
Last Modified: 2008-01-09
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.
Question by:techsuppoprt
    LVL 16

    Accepted Solution

    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.
    LVL 8

    Assisted Solution

    <%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"
        CodeFile="default.aspx.cs" Inherits="default" Title="Untitled Page" %>

    add this code into ur default page
    LVL 1

    Author Comment

    Thanks guys!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now