Update the page properties in master page
<%@ Page Language="C#" MasterPageFile="~/Default.master"
AutoEventWireup="true"
CodeFile="Default.aspx.cs"
Inherits="ProgrammedHome"
Title = "Programmed Master Page Home" %>
<%@ MasterType VirtualPath="~/Default.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="sideContent" Runat="Server">
<h2>title</h2>
<p>AAA</p>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="mainContent" Runat="Server">
<h1>title</h1>
<p>BBB</p>
</asp:Content>
File: Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class ProgrammedHome : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Master.AdImageUrl = "~/Images/ads/ad3.gif";
Master.AdNavigateUrl = "http://www.java2s.com";
}
}
File: Default.master
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Default.master.cs" Inherits="ProgrammedContentMaster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
</head>
<body>
<form id="form1" runat="server">
<div id="container">
<div id="header">
<asp:Image runat="server" ID="imgLogo" ImageUrl="~/cool.gif" />
<div id="bannerAd">
<asp:HyperLink ID="imgbtnAd" runat="server" />
</div>
</div>
<div id="sideArea">
<div id="menu">
<asp:BulletedList ID="blstSample" runat="server" DisplayMode="HyperLink">
<asp:ListItem Value="">Home</asp:ListItem>
<asp:ListItem Value="">Products</asp:ListItem>
<asp:ListItem Value="">About</asp:ListItem>
</asp:BulletedList>
</div>
<div id="sideAreaBox">
<asp:ContentPlaceHolder ID="sideContent" runat="server">
<p>default side content</p>
</asp:ContentPlaceHolder>
</div>
</div>
<div id="mainArea">
<asp:ContentPlaceHolder ID="mainContent" runat="server">
<p>default main content</p>
</asp:ContentPlaceHolder>
</div>
<div id="footer">
<p>this is a test.</p>
</div>
</div>
</form>
</body>
</html>
File: Default.master.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class ProgrammedContentMaster : System.Web.UI.MasterPage
{
public string AdImageUrl
{
get { return imgbtnAd.ImageUrl; }
set { imgbtnAd.ImageUrl = value; }
}
public string AdNavigateUrl
{
get { return imgbtnAd.NavigateUrl; }
set { imgbtnAd.NavigateUrl = value; }
}
}
Related examples in the same category