Bineesh  Viswanath

Bineesh Viswanath

  • NA
  • 1k
  • 777.7k

How to Add MasterPage into WebForms in ASP.NET

Dec 26 2013 3:54 AM
Sir, I need your help to add master page design to webforms in my Applications.
 
 In this , I added both .master page and .aspx page.
 
could you reply how can add master page reference in the webforms . Please tell me by step by step.

Here the MasterPage Contents:-
 
 
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="masterPage.master.cs" Inherits="SchoolAutomation.masterPage" %>

<!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>

<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div >
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
<asp:Menu ID="Menu1" Orientation="Horizontal" runat="server">
<Items>
<asp:MenuItem Text="FILE" Value="file">
<asp:MenuItem Text="NEW" Value="new"></asp:MenuItem>
<asp:MenuItem Text="OPEN" Value="open"></asp:MenuItem>
<asp:MenuItem Text="SAVE" Value="save"></asp:MenuItem>
<asp:MenuItem Text="SAVE AS" Value="saveAs"></asp:MenuItem>
<asp:MenuItem Text="PAGE SETUP" Value="pageSetUp"></asp:MenuItem>
<asp:MenuItem Text="EXIT" Value="exit"></asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem Text="EDIT" Value="edit">
<asp:MenuItem Text="UNDO" Value="undo"></asp:MenuItem>
<asp:MenuItem Text="REDO" Value="redo"></asp:MenuItem>
<asp:MenuItem Text="CUT" Value="cut"></asp:MenuItem>
<asp:MenuItem Text="COPY" Value="copy"></asp:MenuItem>
<asp:MenuItem Text="PASTE" Value="paste"></asp:MenuItem>
<asp:MenuItem Text="FIND" Value="find"></asp:MenuItem>
<asp:MenuItem Text="REPLACE" Value="replace"></asp:MenuItem>
<asp:MenuItem Text="GOTO" Value="goto"></asp:MenuItem>
</asp:MenuItem>
</Items>
</asp:Menu>
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>

 And the webform.aspx file:-
 
 
 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Home.aspx.cs" MasterPageFile="~/masterPage.Master" Inherits="SchoolAutomation.Web_Forms.Home" %>

<!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>
<link href="../StyleSheet/StyleSheet1.css" rel="Stylesheet" type="text/css" />

</head>
<body>
<form id="form1" runat="server">
<div >
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
<asp:PlaceHolder ID="PlaceHolder2" runat="server"></asp:PlaceHolder>

</div>

</form>
</body>
</html>


Answers (1)