Saturday, 22 December 2012 13:55

master pages in

Written by 
Rate this item
(0 votes)

master pages creates a common look in your application.
if we think about the header and footer in our pages,we
create these header and footer in every aspx pages.this
method has disadvantages.if there were any custom page
which dynamically adds header and footer then would be

in,this can be achieved by the built in

a masterpage is same to a .aspx but it has its own
extension .master.this page also contains a master
directive and a contentplaceholder control.
this contentplaceholder control is content area
placeholder where content pages inject data.
a masterpage can hold many contentplaceholder with
respective id's so that correct contentplaceholder is
referenced with it's id.

as a example take a look the following codes for a
master page.

<%@ Master Language=�C#� %>
<head><title>Master Page Tutorial on my blog</title>
<form runat=server>
<asp:ContentPlaceHolder ID=�ContentPlaceHolder1� runat=�server�>
<h1>default content</h1>

after the masterpage is created one can create pages from this
master page template.this content page is look like same
as other content pages but in page directive it will
reference master page and also contains a control and within
this control will be all your data along with content of
corresponding contentplaceholder control in master page.

a example follows with the master page i created above -

<%@ Page Language=�C#� MasterPageFile=�~/demo.master� %>
<asp:Content id=�content� ContentPlaceHolderID=�ContentPlaceHolder1� runat=�server�>
<h1>default content.more content is added</h1>

Read 2785 times
Super User

Email This email address is being protected from spambots. You need JavaScript enabled to view it.

Latest discussions

  • No posts to display.