Custom Controls ASP.Net Tutorial

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"  Inherits="CacheTest" %>
<%@ Register Src="Control.ascx" TagName="CachedWebUserControl" TagPrefix="uc1" %>



    Cache Test


    
    

        
        
         

    


File: Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class CacheTest : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    this.Label1.Text = string.Format("The Time in the Web Page is: {0}",
      DateTime.Now.ToLongTimeString());
    }
}
File: Control.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Control.ascx.cs" Inherits="CachedWebUserControl"  %>
<%@ OutputCache Duration=60 VaryByParam="none" %>

File: Control.ascx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class CachedWebUserControl : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
    this.Label1.Text = string.Format("The Time in the User Control is: {0}",
      DateTime.Now.ToLongTimeString());
    }
}