views:

50

answers:

2

HI. I am new in using WEB applications and Visual tsudio. I was just designing this application and made many .aspx files which have my design's, Now suddenly when i was learning about User Logged Display, I came across the concept of Master Page.

Now it has confused me a lot, Should i once again restart my web application to add Master Page or Is there any other way where i can just introduce this into my project at this stage!? i mean after creating so many pages? or can i make my Default.aspx page as master!?

Please help i am new to this concept and i am tensed for now if i need to again re-create whole project just in case to make my web look nice :(

+1  A: 

Hi, you dont need to use the master system. But if you have content which is changing and the page style should stays the same you can use master pages to just switch the content inside.

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head runat="server">
    <title>title</title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">

        </asp:ContentPlaceHolder>
    </div>
    </form>
</body>
</html>

and its important to add your other .aspx in the @ page header the masterpagefile

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

<asp:Content><p>here could be some content</p></asp:Content>
darkdog
@darkdog i have already created the web pages.. can i add it now i order to make some things look steady?
Nagaraj Tantri
yes you can.. you only need to rightclick you project (at the right) and "Add -> New -> Masterpage" .. there you can just copy in your html code/design ..and dont remove the "Content" tag ;)
darkdog
i've added some code.. the content standing in Default.aspx will just be filled in the ContentPlaceHolder @ the mastersite
darkdog
A: 

You can make a MasterPage file and design it. After that add a new .aspx file and check the use MasterPage and select the one you've made. Then see the differences in the XML files between one of your sites and the newly created one and make changes on all XML files to look like the new one. ..they don't have head and body, they only would have the import of MasterPage tag I think.

Kex