Creating a User Control Cache File Dependency : User Control « Cache « ASP.NET Tutorial






File: Control.ascx

<%@ Control Language="C#" ClassName="ProductFileDependency"
%> <%@ OutputCache Duration="9999" VaryByParam="none" %>
<script runat="server">

    void Page_Load()
    {
        CacheDependency depend = new CacheDependency(MapPath("~/Products.xml"));
        this.CachePolicy.Dependency = depend;
    }
</script>
User Control Time:
<%= DateTime.Now.ToString("T") %>
<hr />

<asp:GridView
    id="grdProducts"
    DataSourceID="srcProducts"
    Runat="server" />
<asp:XmlDataSource
    id="srcProducts"
    DataFile="Products.xml"
    Runat="server" />








13.15.User Control
13.15.1.Caching with a User Control
13.15.2.Sharing a User Control Output Cache
13.15.3.Creating a User Control Cache File Dependency
13.15.4.Programmatically caching a User Control.