<%@ outputcache duration=120 varybyparam="none" %>
<html>
<head>
<title>Substitution Control Example</title>
<link rel="stylesheet" href="/shared/netdemos.css">
<script language="C#" runat="server">
void Page_Load ( object src, System.EventArgs e ) {
// display the current date and time in the label.
// output caching applies to this section of the page.
cachedContent.Text = DateTime.Now.ToString ( );
}
// the Substitution control calls this method to retrieve the current date and time.
// this section of the page is exempt from output caching.
public static string getCurrentDateTime ( HttpContext context ) {
return DateTime.Now.ToString ( );
}
</script>
</head>
<body>
<!-- #include virtual="~/shared/top.inc -->
<div class="header"><h2>Substitution Control Example</h2></div>
<!-- #include virtual="~/shared/viewsrc_top.inc" -->
<hr size=1 width=92%>
<div align="center">
<form runat="server">
<p>This section of the page is cached</p>
<asp:label id="cachedContent" runat="Server" />
<p>This section of the page is exempt from output caching</p>
<p id="msg"><asp:substitution id="subContent"
methodname="getCurrentDateTime"
runat="Server" /></p>
<p><asp:button id="RefreshButton"
text="Refresh Page"
runat="Server" /></p>
</form>
</div>
<hr size=1 width=92%>
<!-- #include virtual="~/shared/viewsrc.inc" -->
</body>
</html>