A master page that exposes a custom property (C#)
<%@ Page Language="C#" MasterPageFile="~/Default.master" %>
<%@ MasterType VirtualPath="~/Default.master" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
Master.PageHeadingTitle = "My Company ?Division X";
}
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"/>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server"/>
File: Default.master
<%@ Master Language="C#" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Label1.Text = System.Guid.NewGuid().ToString();
}
}
string m_PageHeadingTitle = "My Company";
public string PageHeadingTitle
{
get
{
return m_PageHeadingTitle;
}
set
{
m_PageHeadingTitle = value;
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>My Company Master Page</title>
</head>
<body>
<form id="Form1" runat="server">
<table>
<tr>
<td>
<h1><%= PageHeadingTitle%></h1>
<b>User's GUID:
<asp:Label ID="Label1" Runat="server" /></b>
</td>
</tr>
<tr>
<td>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" Runat="server"/>
</td>
<td>
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" Runat="server"/>
</td>
</tr>
<tr>
<td colspan="2">
Copyright 2004 - My Company
</td>
</tr>
</table>
</form>
</body>
</html>
Related examples in the same category