How to use Master page in ASP.NET [Resolved]

Posted by Saranya Boopathi under ASP.NET on 8/22/2012 | Points: 10 | Views : 4350 | Status : [Member] | Replies : 13
I know what is the purpose of master page.But dont know how to inherit that page to other page.Please give some Example for my understanding..
Thanks in Advance

By
Saranya

Saranya Boopathi


Responses

Posted by: Gopesh9 on: 8/22/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
In your aspx page you will get the ContentPlaceHolder, there you have to do all your stuffs i.e. all the controls which you want...You can have more than one ContentplaceHolder in one page, You will not have any body,script in that page....

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


<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</asp:Content>


G. S.
.Net Developer

Saranya Boopathi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lalitha86 on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
Create a master page and after that add that Master Page When u are using that page
Just select that Master page
It will automatically inherit that master page


Saranya Boopathi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gopesh9 on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
At first Create a Master page like MyMaterPage.master
Now when you add a new item in that project say firstPage.aspx you will get a window. At the right side bottom of that window you will get a checkbox asking for "Select Master Page", when you will check that checkbox, your master page will be attached with your aspx page...

G. S.
.Net Developer

Saranya Boopathi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Saranya Boopathi on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
Master page is Attached...but how to design that page

Saranya Boopathi

Saranya Boopathi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lalitha86 on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
v

Saranya Boopathi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gopesh9 on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
You can design that page as same as that of your aspx page. Simply you can drag and drop the controls from the toolbox, you can write the code of that controls in the master page itself..

G. S.
.Net Developer

Saranya Boopathi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Saranya Boopathi on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
I can design the master page but after attaching that master page the aspx page is block.Than how can i degisn that aspx page

Saranya Boopathi

Saranya Boopathi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Saranya Boopathi on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
How to design the contentpage after i attached the master page.when i attached the master page the design of master pages are inherited but i dont know how to design the content page based on requirement

Saranya Boopathi

Saranya Boopathi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lalitha86 on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
In the Master page u will add u r menus and if u want the the user controls and header and footer

and in u r page for example if it is the login page

then u r login textbox and its function and code


In Master Page Only we use that things which are going to be common on all pages



Saranya Boopathi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Saranya Boopathi on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Gopesh9 ,

In this ContentPlaceHolder1 shows an Error

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

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</asp:Content>



Saranya Boopathi

Saranya Boopathi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Gopesh9 on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
May be the name of the MasterPageFile is different or CodeFile name is different in your application...

G. S.
.Net Developer

Saranya Boopathi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rambabu123 on: 8/22/2012 [Member] Starter | Points: 25

Up
0
Down
<%@ Page Language="C#" MasterPageFile="~/Private/MasterPages/CommonMasterPage.master"
AutoEventWireup="true" CodeFile="AccreditedBy.aspx.cs" Inherits="Private_Admin_View_AccreditedBy"
Title="Accredited By" %>

Here After U creating masterpage That master apge u will give path name of master page like....... at the top page directive tag
MasterPageFile="~/Private/MasterPages/CommonMasterPage.master"


i think it is useful for u



Saranya Boopathi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Saranya Boopathi on: 8/23/2012 [Member] Starter | Points: 25

Up
0
Down
Thanks I got it

Saranya Boopathi

Saranya Boopathi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response