Master Page code:
<%@ 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 "><HTMLxmlns= "http://www.w3.org/1999/xhtml"><Headrunat= "Server"> <title>No title page</title> <Scripttype= "Text/javascript"src= "Js/jscript.js"></Script> <Scripttype= "Text/javascript"language= "JavaScript">$ (document). Ready (function(){ $("#a1"). Click (function() {alert ("Parent Page"); }); }); </Script> <Asp:contentplaceholderID= "Head"runat= "Server"> </Asp:contentplaceholder></Head><Bodystyle= "Background-color:gray;"> <Divstyle= "width:1050px; Background-color:yellow; margin:0 auto; "> <Divstyle= "background-color:red; margin:0 auto; position:relative; margin-top:10px; height:200px; "> <P>Top of page</P><aID= "A1"href="#">Login</a> </Div> <Asp:contentplaceholderID= "ContentPlaceHolder1"runat= "Server"> </Asp:contentplaceholder> <Divstyle= "background-color:blue;margin:0 auto; position:relative; margin-top:10px; height:200px; "><P>Bottom of page</P></Div></Div></Body></HTML>
Sub-page code:
<%@ Page Language="C #"MasterPageFile="~/masterpage.master"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_default"Title="No title page" %><asp:contentID= "Content1"ContentPlaceHolderID= "Head"runat= "Server"> <Scripttype= "Text/javascript">$ (document). Ready (function(){ $("#a2"). Click (function() {alert ("Sub-page");}); }); </Script></asp:content><asp:contentID= "Content2"ContentPlaceHolderID= "ContentPlaceHolder1"runat= "Server"><Divstyle= "position:relative; margin-top:10px; height:300px; Background-color:white; "><aID= "A2"href="#">Sub-page</a></Div></asp:content>
How to use the ASP. NET Master Page