substitution控件:在页面输出缓存状态,保持部分数据的动态更新
2007-12-12 23:32
676 查看
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
//缓存整个页面,采用页面输出缓存一样达到同样的效果
//<%@ OutputCache Duration="60" VaryByParam="none" %>
Response.Cache.SetExpires(DateTime.Now.AddSeconds(40));
Response.Cache.SetCacheability(HttpCacheability.Public);
//Response.Cache.SetValidUntilExpires(true);
}
private static string getTime(HttpContext context)
{
return DateTime.Now.ToString();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
substitution控件可以让缓存的页面部分刷新,从而保持部分数据的动态更新。<br />
该时间将被缓存:<%= DateTime.Now.ToString() %><br />
尽管整个页面被缓存,但是下面的时间却不会,因为我们用了substitution控件。<br />
当前时间:
<span style="color:Red; font-weight:bold;"><asp:Substitution ID="subTime" runat="server" MethodName="getTime" /></span> <br />
给Substitution控件的属性<i><b>MethodName</b></i>指定一个带<i><b>HttpContext参数</b></i>的<i><b>静态方法</b></i>,<br />
返回的数据将在该控件中显示。<br />
<span style="color:Blue;">private <b>static</b> string getTime(<b>HttpContext</b> context)</span>
<br />
</div>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
//缓存整个页面,采用页面输出缓存一样达到同样的效果
//<%@ OutputCache Duration="60" VaryByParam="none" %>
Response.Cache.SetExpires(DateTime.Now.AddSeconds(40));
Response.Cache.SetCacheability(HttpCacheability.Public);
//Response.Cache.SetValidUntilExpires(true);
}
private static string getTime(HttpContext context)
{
return DateTime.Now.ToString();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
substitution控件可以让缓存的页面部分刷新,从而保持部分数据的动态更新。<br />
该时间将被缓存:<%= DateTime.Now.ToString() %><br />
尽管整个页面被缓存,但是下面的时间却不会,因为我们用了substitution控件。<br />
当前时间:
<span style="color:Red; font-weight:bold;"><asp:Substitution ID="subTime" runat="server" MethodName="getTime" /></span> <br />
给Substitution控件的属性<i><b>MethodName</b></i>指定一个带<i><b>HttpContext参数</b></i>的<i><b>静态方法</b></i>,<br />
返回的数据将在该控件中显示。<br />
<span style="color:Blue;">private <b>static</b> string getTime(<b>HttpContext</b> context)</span>
<br />
</div>
</form>
</body>
</html>
相关文章推荐
- ASP.Net 更新页面输出缓存的几种方法(包括用户控件,iframe,页面缓存等)
- .net2.0中新增的Substitution控件--动态更新缓存页的部分(也可用于局部刷新)
- .net2.0中新增的Substitution控件--动态更新缓存页的部分(也可用于局部刷新)
- ASP.Net 更新页面输出缓存的几种方法(包括用户控件,iframe,页面缓存等)
- Substitution控件----动态更新缓存页的部分
- ASP.Net 更新页面输出缓存的几种方法(包括用户控件,iframe,页面缓存等)
- ASP.Net 更新页面输出缓存的几种方法(包括用户控件,iframe,页面缓存等)(转)
- Substitution控件----动态更新缓存页的部分
- Substitution控件----动态更新缓存页的部分
- ASP.Net 更新页面输出缓存的几种方法(包括用户控件,iframe,页面缓存等)
- ASP.Net 更新页面输出缓存的几种方法(包括用户控件,iframe,页面缓存等)
- ASP.Net 更新页面输出缓存的几种方法
- 验证GridView控件在编辑状态下输入的数据是否合法(不合法,不允许更新,同时弹出提示框)
- 在页面切换时使用RxJava持续更新控件状态
- 在aspx页动态加载ascx页面内容,给GridView控件绑定数据
- 关闭子页面刷新父页面中部分控件数据的方法
- ASP.NET 4中的可扩展输出缓存(可以缓存页面/控件等)
- ie浏览器缓存不能更新页面数据
- asp.net 使用驻留在页面中的Cache缓存常用可定时更新的数据
- 静态页面设置缓存、动态页面设缓存(不断更新中。。。。)