Jump to content

master page problem !!


huseyin

Recommended Posts

hi i am a student doing my graduation project,i am designing a web application by using asp.net2005 , i have 8 pages in my project, and i need to add a Master page (which i know very little about) to my project, but i dont know how to combine master page with already done pages. can anybody help ? i will be very happy , thank you for ur replies

Link to comment
Share on other sites

Here's a sample Master Page:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="DefaultPage.master.cs" Inherits="DefaultMasterPage" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"><title></title></head><body><asp:ContentPlaceHolder ID="MainContentPlaceHolder" runat="server" /></body></html>

And a page that would use it:

<%@ Page Language="C#" MasterPageFile="DefaultPage.master" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" Title="Test Page" %><asp:Content ID="Content" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">Hello World!</asp:Content>

The code that is in the <asp:Content></asp:Content> element will be placed in the ContentPlaceHolder of the master page.

Link to comment
Share on other sites

What is a "master" page? What is the difference between that and a "normal" page?
It's a .NET 2.0 attempt at creating templates for sites. If you set up a master page with most of your layout design, you could then build a series of pages that use that master page to display the content. Kind of like using includes in PHP.I haven't played around with them too much, but that's what I've discovered so far.
Link to comment
Share on other sites

Here's a sample Master Page:
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="DefaultPage.master.cs" Inherits="DefaultMasterPage" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"><title></title></head><body><asp:ContentPlaceHolder ID="MainContentPlaceHolder" runat="server" /></body></html>

And a page that would use it:

<%@ Page Language="C#" MasterPageFile="DefaultPage.master" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" Title="Test Page" %><asp:Content ID="Content" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">Hello World!</asp:Content>

The code that is in the <asp:Content></asp:Content> element will be placed in the ContentPlaceHolder of the master page.

Umm . . . does it always need XHTML for asp? Iv'e tried few asp's on HTML that is effortless.
Link to comment
Share on other sites

Umm . . . does it always need XHTML for asp? Iv'e tried few asp's on HTML that is effortless.
That's just the way my version of Visual Studio (2005) created the master page. Just like any website, you don't need to use XHTML.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...