SamuelWang

导航

以用户控件进行asp.net网页的部分缓存

建立一个用户控件 myEmployees.ascx ,
在myEmployees.ascx.cs中, 加入网页10秒缓存
Code
设置Page每秒画面更新
在使用myEmployees.ascx 空间的页面上加上
    <meta http-equiv="refresh" content="1;URL=UserControlCaching.aspx" />
UserControlCaching.aspx 是使用用户控件的页面
Code

另外 使用 Substitution 控件也可以自动根据 outputcache缓存设置来 缓存数据,GetTime是服务器方法。
   <asp:Substitution ID="Substitution1" runat="server" MethodName="GetTime" />
Substitution 控件也可以再后台动态加入
前台:
 <td style="width: 291px">
                
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
            
</td>
后台:
Code

广告控件 AdRotator 可以根据outputcache缓存设置来更换广告内容
Code

页面上:
 <asp:AdRotator ID="AdRotator1" runat="server" AdvertisementFile="~/App_Data/Advertisements.xml" />

posted on 2009-10-06 13:01  人生若只如初见  阅读(291)  评论(0编辑  收藏  举报