ASP.NET自定义输出缓存提供程序(5)
Inherits="_19_1.MyOutputCacheProviderUserControl" %>
<%@ OutputCache Duration="30" VaryByParam="none" ProviderName="MyOutputCacheProvider" %>
<asp:Label ID="Label1" runat="server" />
MyOutputCacheProviderUserControl.ascx.cs代码如下所示:
public partial class MyOutputCacheProviderUserControl :System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
this.Label1.Text=DateTime.Now.ToLongTimeString();
}
}
定义好MyOutputCacheProviderUserControl用户控件之后,下面我们继续来定义一个测试页面MyOutputCacheProviderWebForm.aspx,代码如下所示:
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="MyOutputCacheProviderWebForm.aspx.cs"
Inherits="_19_1.MyOutputCacheProviderWebForm" %>
<%@ Register src="MyOutputCacheProviderUserControl.ascx"
tagname="MyOutputCacheProviderUserControl" tagprefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="刷新页面" />
<br />
MyOutputCacheProviderUserControl:
<uc1:MyOutputCacheProviderUserControl ID="MyOutputCacheProviderUserControl1" runat="server" />
<br />
MyOutputCacheProviderWebForm
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>
</html>
MyOutputCacheProviderWebForm.aspx.cs代码如下所示:
public partial class MyOutputCacheProviderWebForm :
System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.Label1.Text=DateTime.Now.ToLongTimeString();
相关新闻>>
- 发表评论
-
- 最新评论 更多>>