Create a page cachingdemo.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="cachingdemo.aspx.cs" Inherits="cachingdemo" %><%@ OutputCache Duration="60" VaryByParam="None" %><!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>Caching Demo</title></head><body><form id="form1" runat="server"><div><h2 style="color:Red">Output Caching</h2><asp:LabelID="Label1"runat="server"Font-Size="Large"ForeColor="SeaGreen"Text="Output Caching Duration: 60 seconds."></asp:Label><br /><br /><asp:LabelID="Label2"runat="server"Font-Size="Large"ForeColor="DodgerBlue"></asp:Label></div></form></body></html>
Write the code on Page_Load event
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 cachingdemo : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){Label2.Text = "Present Time: ";Label2.Text += DateTime.Now.ToString();}}
Output:
Comments
Post a Comment