Click here to Skip to main content
15,888,527 members
Articles / Web Development / ASP.NET

How to manipulate master page controls in ASP.NET when output caching is enabled

Rate me:
Please Sign up or sign in to vote.
4.68/5 (14 votes)
21 Aug 2012CPOL7 min read 78.8K   802   21  
This short article shows how to manipulate master page controls in ASP.NET when output caching is enabled.
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" 
Inherits="MasterPageControlExample.SiteMaster" %>

<%@ Register Src="Controls/Header.ascx" TagName="Header" TagPrefix="uc1" %>
<%@ Register Src="Controls/Footer.ascx" TagName="Footer" TagPrefix="uc2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
    <title></title>
    <link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder ID="HeadContent" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>
    <form runat="server">
    <div class="page">
        <asp:PlaceHolder ID="PlaceHolderHeader" runat="server">
            <uc1:Header ID="Header1" runat="server" />
        </asp:PlaceHolder>
        <div>
            <h2>
                <a href="Default.aspx">Default.aspx</a><br />
                <a href="About.aspx">About.aspx</a><br />
                <a href="Report.aspx">Report.aspx</a><br />
            </h2>
        </div>
        <div class="main">
            <asp:ContentPlaceHolder ID="MainContent" runat="server" />
        </div>
        <div class="clear">
        </div>
    </div>
    <asp:PlaceHolder ID="PlaceHolderFooter" runat="server">
        <uc2:Footer ID="Footer1" runat="server" />
    </asp:PlaceHolder>
    </form>
</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Riteq
Australia Australia
About Md. Masudur Rahman

Masudur currently works at Riteq as a software developer. Masudur Lives in Sydney, Australia.

Awards

26 May 2009: Monthly competition: Best ASP.NET article of April 2009

24 Mar 2009: Monthly competition: Best ASP.NET article of February 2009

Masudur Blog

Masudur put down his interesting learning experiences in his blog at http://munnaondotnet.blogspot.com/.

Comments and Discussions