Community-Credit.com | NonProfitWays.com | SOAPitstop.com   Skin:   
      User: Not logged in 
Home
Newsletter Signup
XSLT Library
Latest XML Blogs
Featured Examples
Presentations
Featured Articles
Book Chapters
Training Courses
Events
NewsGroups
 
Discussions
Examples
Tutorials
Tools
Articles
Resources
Websites
 
Sign In
My Profile
My Articles
My Examples
My Favorites
My Resources
Add a Resource
Logout
 
About Me
My Blog
HeadGeek Articles
Talking Portfolio
Resume
Pictures
World Trip Pics

Caching in ASP.NET 2.0
Author: Unknown
Published: 7/22/2005 9:24 PM
Category: ADO.NET, ASP.NET, Caching, Database, Datagrid, Datalist, DTD, Schema, SQL, SQLXML, VB.NET, XHTML, XML
Summary: CreateDairyProductsDependency.sql; new features are Declarative.aspx page, Filtered.aspx page, and Filtered_2005.aspx page.

 

1)aspnet_regsql.txt:

aspnet_regsql.exe -?

 

aspnet_regsql.exe -E -d Northwind -ed

 

aspnet_regsql -E -d Northwind -t Categories -et

 

aspnet_regsql.exe -E -d Northwind -lt

 

aspnet_regsql.exe -E -d Northwind -dd

2)CacheProfile.aspx:

<%@ Page AutoEventWireup="false" ClassName="CacheProfile_aspx" CompileWith="CacheProfile.aspx.vb" Language="VB" %>

<%@ OutputCache CacheProfile = "ShortTime" SqlDependency = "NorthwindDependency:Categories" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Cache Profile</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<asp:SqlDataSource ID="SqlDataSource1" Runat="server"

SelectCommand="SELECT [CategoryID], [CategoryName], [Description] FROM [Categories]"

ConnectionString="<%$ ConnectionStrings:NorthwindConnection %>">

</asp:SqlDataSource><br />

<asp:GridView ID="GridView1" Runat="server" DataKeyNames="CategoryID" DataSourceID="SqlDataSource1"

EmptyDataText="There are no data records to display." AutoGenerateColumns="False"

BorderWidth="1px" BackColor="White" CellPadding="4" BorderStyle="None" BorderColor="#3366CC">

<FooterStyle ForeColor="#003399" BackColor="#99CCCC"></FooterStyle>

<PagerStyle ForeColor="#003399" HorizontalAlign="Left" BackColor="#99CCCC"></PagerStyle>

<HeaderStyle ForeColor="#CCCCFF" Font-Bold="True" BackColor="#003399"></HeaderStyle>

<Columns>

<asp:BoundField ReadOnly="True" HeaderText="CategoryID" DataField="CategoryID" SortExpression="CategoryID"></asp:BoundField>

<asp:BoundField HeaderText="CategoryName" DataField="CategoryName" SortExpression="CategoryName"></asp:BoundField>

<asp:BoundField HeaderText="Description" DataField="Description" SortExpression="Description"></asp:BoundField>

</Columns>

<SelectedRowStyle ForeColor="#CCFF99" Font-Bold="True" BackColor="#009999"></SelectedRowStyle>

<RowStyle ForeColor="#003399" BackColor="White"></RowStyle>

</asp:GridView><br />

<asp:Label ID="lblLoadTime" Runat="server" Text="Page_Load last ran at:" Width="294px"

Height="24px"></asp:Label>

</div>

</form>

</body>

</html>

3)CacheProfile.aspx.vb:

Partial Class CacheProfile_aspx

Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

lblLoadTime.Text = "Page_Load last ran at: " _

& DateTime.Now.ToString("HH:mm:ss")

End Sub

End Class

4)Caching.sln:

Microsoft Visual Studio Solution File, Format Version 9.00

# Visual Studio 2005

Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "C:\ASPNET20VB\Caching\", "C:\ASPNET20VB\Caching\", "{26CE652A-8BAD-405E-9C2E-FE8A62E4C86A}"

ProjectSection(WebsiteProperties) = preProject

VWDPort = 1286

EndProjectSection

EndProject

Global

GlobalSection(SolutionConfigurationPlatforms) = preSolution

Debug|.NET = Debug|.NET

EndGlobalSection

GlobalSection(ProjectConfigurationPlatforms) = postSolution

{26CE652A-8BAD-405E-9C2E-FE8A62E4C86A}.Debug|.NET.ActiveCfg = Debug|.NET

{26CE652A-8BAD-405E-9C2E-FE8A62E4C86A}.Debug|.NET.Build.0 = Debug|.NET

EndGlobalSection

GlobalSection(SolutionProperties) = preSolution

HideSolutionNode = FALSE

EndGlobalSection

EndGlobal

5)CreateDairyProductsDependency.sql

-- Run only after enabling the Northwind database for caching with aspnet_regsql.

-- Disabling the database for caching will automatically drop these objects.

Use Northwind

-- Add a row for 'DiaryProducts' to the tracking table.

IF NOT EXISTS (SELECT tableName FROM dbo.AspNet_SqlCacheTablesForChangeNotification WITH (TABLOCKX) WHERE tableName = 'DairyProducts')

-- Add a row for 'DiaryProducts' to the tracking table

INSERT dbo.AspNet_SqlCacheTablesForChangeNotification

VALUES ('DairyProducts', GETDATE(), 0)

GO

-- Create a trigger on Products that only runs when

-- a product with CategoryID=4 is inserted, updated, or deleted.

IF EXISTS (SELECT name

FROM sysobjects

WHERE name = N'DairyProducts_AspNet_SqlCacheNotification_Trigger'

AND type = 'TR')

DROP TRIGGER DairyProducts_AspNet_SqlCacheNotification_Trigger

GO

CREATE TRIGGER dbo.[DairyProducts_AspNet_SqlCacheNotification_Trigger] ON dbo.Products

FOR INSERT, UPDATE, DELETE AS

BEGIN

SET NOCOUNT ON

IF EXISTS (SELECT ProductID FROM inserted WHERE CategoryID = 4)

OR EXISTS (SELECT ProductID FROM deleted WHERE CategoryID = 4)

EXEC dbo.AspNet_SqlCacheUpdateChangeIdStoredProcedure N'DairyProducts'

END

6)Declarative.aspx:

<%@ Page AutoEventWireup="false" ClassName="Declarative_aspx" CompileWith="Declarative.aspx.vb" Language="VB" %>

<%@ OutputCache SqlDependency = "NorthwindDependency:Categories" Duration="9999999" VaryByParam="None" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Declarative SqlCacheDependency</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<asp:SqlDataSource ID="SqlDataSource1" Runat="server"

SelectCommand="SELECT [CategoryID], [CategoryName], [Description] FROM [Categories]"

ConnectionString="<%$ ConnectionStrings:NorthwindConnection %>">

</asp:SqlDataSource><br />

<asp:GridView ID="GridView1" Runat="server" DataKeyNames="CategoryID" DataSourceID="SqlDataSource1"

EmptyDataText="There are no data records to display." AutoGenerateColumns="False"

BorderWidth="1px" BackColor="White" CellPadding="4" BorderStyle="None" BorderColor="#3366CC">

<FooterStyle ForeColor="#003399" BackColor="#99CCCC"></FooterStyle>

<PagerStyle ForeColor="#003399" HorizontalAlign="Left" BackColor="#99CCCC"></PagerStyle>

<HeaderStyle ForeColor="#CCCCFF" Font-Bold="True" BackColor="#003399"></HeaderStyle>

<Columns>

<asp:BoundField ReadOnly="True" HeaderText="CategoryID" DataField="CategoryID" SortExpression="CategoryID"></asp:BoundField>

<asp:BoundField HeaderText="CategoryName" DataField="CategoryName" SortExpression="CategoryName"></asp:BoundField>

<asp:BoundField HeaderText="Description" DataField="Description" SortExpression="Description"></asp:BoundField>

</Columns>

<SelectedRowStyle ForeColor="#CCFF99" Font-Bold="True" BackColor="#009999"></SelectedRowStyle>

<RowStyle ForeColor="#003399" BackColor="White"></RowStyle>

</asp:GridView><br />

<asp:Label ID="lblLoadTime" Runat="server" Text="Page_Load last ran at:" Width="294px"

Height="24px"></asp:Label>

</div>

</form>

</body>

</html>

7)Declarative.aspx.vb:

Partial Class Declarative_aspx

Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

lblLoadTime.Text = "Page_Load last ran at: " _

& DateTime.Now.ToString("HH:mm:ss")

End Sub

End Class

8)Default.aspx:

<%@ Page AutoEventWireup="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head id="Head1" runat="server">

<title>Caching</title>

<link href="StyleSheet.css" type="text/css" rel="stylesheet" />

</head>

<body>

<form id="form1" runat="server">

<div>

<h1>

New Caching Features</h1>

<div>

<asp:HyperLink ID="HyperLink1" Runat="server" NavigateUrl="Declarative.aspx">Declarative SqlCacheDependency</asp:HyperLink>

<br />

<br />

<asp:HyperLink ID="HyperLink2" Runat="server" NavigateUrl="SqlDataSourceControl.aspx">SqlDataSource Control Support</asp:HyperLink>

<br />

<br />

<asp:HyperLink ID="HyperLink3" Runat="server" NavigateUrl="Filtered.aspx">Caching Filtered Data</asp:HyperLink>

<br />

<br />

<asp:HyperLink ID="HyperLink4" Runat="server" NavigateUrl="CacheProfile.aspx">Cache Profiles</asp:HyperLink>

<br />

<br />

<asp:HyperLink ID="HyperLink5" Runat="server" NavigateUrl="Substitution.aspx">Post-Cache Substitution</asp:HyperLink>

<br />

</div>

</div>

</form>

</body>

</html>

8)Filtered.aspx:

<%@ Page AutoEventWireup="false" ClassName="Filtered_aspx" CompileWith="Filtered.aspx.vb" Language="VB" %>

<%@ OutputCache SqlDependency = "NorthwindDependency:DairyProducts" Duration="9999999" VaryByParam="None" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Filtered SqlCacheDependency</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<asp:SqlDataSource ID="SqlDataSource1" Runat="server"

SelectCommand="SELECT [ProductID], [ProductName], [UnitsInStock] FROM [Products] WHERE CategoryID = 4"

ConnectionString="<%$ ConnectionStrings:NorthwindConnection %>">

</asp:SqlDataSource><br />

<h3>Dairy Products</h3>

<asp:GridView ID="GridView1" Runat="server" DataKeyNames="ProductID" DataSourceID="SqlDataSource1"

EmptyDataText="There are no data records to display." AutoGenerateColumns="False"

BorderWidth="1px" BackColor="White" CellPadding="4" BorderStyle="None" BorderColor="#3366CC">

<FooterStyle ForeColor="#003399" BackColor="#99CCCC"></FooterStyle>

<PagerStyle ForeColor="#003399" HorizontalAlign="Left" BackColor="#99CCCC"></PagerStyle>

<HeaderStyle ForeColor="#CCCCFF" Font-Bold="True" BackColor="#003399"></HeaderStyle>

<Columns>

<asp:BoundField ReadOnly="True" HeaderText="ProductID" DataField="ProductID" SortExpression="ProductID"></asp:BoundField>

<asp:BoundField HeaderText="ProductName" DataField="ProductName" SortExpression="ProductName"></asp:BoundField>

<asp:BoundField HeaderText="UnitsInStock" DataField="UnitsInStock" SortExpression="UnitsInStock"></asp:BoundField>

</Columns>

<SelectedRowStyle ForeColor="#CCFF99" Font-Bold="True" BackColor="#009999"></SelectedRowStyle>

<RowStyle ForeColor="#003399" BackColor="White"></RowStyle>

</asp:GridView><br />

<asp:Label ID="lblLoadTime" Runat="server" Text="Page_Load last ran at:" Width="294px"

Height="24px"></asp:Label>

</div>

</form>

</body>

</html>

9)Filtered.aspx.vb:

<%@ Page AutoEventWireup="false" ClassName="Filtered_aspx" CompileWith="Filtered.aspx.vb" Language="VB" %>

<%@ OutputCache SqlDependency = "NorthwindDependency:DairyProducts" Duration="9999999" VaryByParam="None" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Filtered SqlCacheDependency</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<asp:SqlDataSource ID="SqlDataSource1" Runat="server"

SelectCommand="SELECT [ProductID], [ProductName], [UnitsInStock] FROM [Products] WHERE CategoryID = 4"

ConnectionString="<%$ ConnectionStrings:NorthwindConnection %>">

</asp:SqlDataSource><br />

<h3>Dairy Products</h3>

<asp:GridView ID="GridView1" Runat="server" DataKeyNames="ProductID" DataSourceID="SqlDataSource1"

EmptyDataText="There are no data records to display." AutoGenerateColumns="False"

BorderWidth="1px" BackColor="White" CellPadding="4" BorderStyle="None" BorderColor="#3366CC">

<FooterStyle ForeColor="#003399" BackColor="#99CCCC"></FooterStyle>

<PagerStyle ForeColor="#003399" HorizontalAlign="Left" BackColor="#99CCCC"></PagerStyle>

<HeaderStyle ForeColor="#CCCCFF" Font-Bold="True" BackColor="#003399"></HeaderStyle>

<Columns>

<asp:BoundField ReadOnly="True" HeaderText="ProductID" DataField="ProductID" SortExpression="ProductID"></asp:BoundField>

<asp:BoundField HeaderText="ProductName" DataField="ProductName" SortExpression="ProductName"></asp:BoundField>

<asp:BoundField HeaderText="UnitsInStock" DataField="UnitsInStock" SortExpression="UnitsInStock"></asp:BoundField>

</Columns>

<SelectedRowStyle ForeColor="#CCFF99" Font-Bold="True" BackColor="#009999"></SelectedRowStyle>

<RowStyle ForeColor="#003399" BackColor="White"></RowStyle>

</asp:GridView><br />

<asp:Label ID="lblLoadTime" Runat="server" Text="Page_Load last ran at:" Width="294px"

Height="24px"></asp:Label>

</div>

</form>

</body>

</html>

10)Filtered_2005.aspx

<%@ Page AutoEventWireup="false" ClassName="Filtered_aspx" CompileWith="Filtered.aspx.vb" Language="VB" %>

<%@ OutputCache SqlDependency = "NorthwindDependency:DairyProducts" Duration="9999999" VaryByParam="None" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Filtered SqlCacheDependency</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<asp:SqlDataSource ID="SqlDataSource1" Runat="server"

SelectCommand="SELECT [ProductID], [ProductName], [UnitsInStock] FROM [Products] WHERE CategoryID = 4"

ConnectionString="<%$ ConnectionStrings:NorthwindConnection %>">

</asp:SqlDataSource><br />

<h3>Dairy Products</h3>

<asp:GridView ID="GridView1" Runat="server" DataKeyNames="ProductID" DataSourceID="SqlDataSource1"

EmptyDataText="There are no data records to display." AutoGenerateColumns="False"

BorderWidth="1px" BackColor="White" CellPadding="4" BorderStyle="None" BorderColor="#3366CC">

<FooterStyle ForeColor="#003399" BackColor="#99CCCC"></FooterStyle>

<PagerStyle ForeColor="#003399" HorizontalAlign="Left" BackColor="#99CCCC"></PagerStyle>

<HeaderStyle ForeColor="#CCCCFF" Font-Bold="True" BackColor="#003399"></HeaderStyle>

<Columns>

<asp:BoundField ReadOnly="True" HeaderText="ProductID" DataField="ProductID" SortExpression="ProductID"></asp:BoundField>

<asp:BoundField HeaderText="ProductName" DataField="ProductName" SortExpression="ProductName"></asp:BoundField>

<asp:BoundField HeaderText="UnitsInStock" DataField="UnitsInStock" SortExpression="UnitsInStock"></asp:BoundField>

</Columns>

<SelectedRowStyle ForeColor="#CCFF99" Font-Bold="True" BackColor="#009999"></SelectedRowStyle>

<RowStyle ForeColor="#003399" BackColor="White"></RowStyle>

</asp:GridView><br />

<asp:Label ID="lblLoadTime" Runat="server" Text="Page_Load last ran at:" Width="294px"

Height="24px"></asp:Label>

</div>

</form>

</body>

</html>

11)Filtered_2005.aspx.vb:

<%@ Page AutoEventWireup="false" ClassName="Filtered_aspx" CompileWith="Filtered.aspx.vb" Language="VB" %>

<%@ OutputCache SqlDependency = "NorthwindDependency:DairyProducts" Duration="9999999" VaryByParam="None" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Filtered SqlCacheDependency</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<asp:SqlDataSource ID="SqlDataSource1" Runat="server"

SelectCommand="SELECT [ProductID], [ProductName], [UnitsInStock] FROM [Products] WHERE CategoryID = 4"

ConnectionString="<%$ ConnectionStrings:NorthwindConnection %>">

</asp:SqlDataSource><br />

<h3>Dairy Products</h3>

<asp:GridView ID="GridView1" Runat="server" DataKeyNames="ProductID" DataSourceID="SqlDataSource1"

EmptyDataText="There are no data records to display." AutoGenerateColumns="False"

BorderWidth="1px" BackColor="White" CellPadding="4" BorderStyle="None" BorderColor="#3366CC">

<FooterStyle ForeColor="#003399" BackColor="#99CCCC"></FooterStyle>

<PagerStyle ForeColor="#003399" HorizontalAlign="Left" BackColor="#99CCCC"></PagerStyle>

<HeaderStyle ForeColor="#CCCCFF" Font-Bold="True" BackColor="#003399"></HeaderStyle>

<Columns>

<asp:BoundField ReadOnly="True" HeaderText="ProductID" DataField="ProductID" SortExpression="ProductID"></asp:BoundField>

<asp:BoundField HeaderText="ProductName" DataField="ProductName" SortExpression="ProductName"></asp:BoundField>

<asp:BoundField HeaderText="UnitsInStock" DataField="UnitsInStock" SortExpression="UnitsInStock"></asp:BoundField>

</Columns>

<SelectedRowStyle ForeColor="#CCFF99" Font-Bold="True" BackColor="#009999"></SelectedRowStyle>

<RowStyle ForeColor="#003399" BackColor="White"></RowStyle>

</asp:GridView><br />

<asp:Label ID="lblLoadTime" Runat="server" Text="Page_Load last ran at:" Width="294px"

Height="24px"></asp:Label>

</div>

</form>

</body>

</html>

12)SqlDataSourceControl.aspx:

<%@ Page AutoEventWireup="false" ClassName="Filtered_aspx" CompileWith="Filtered.aspx.vb" Language="VB" %>

<%@ OutputCache SqlDependency = "NorthwindDependency:DairyProducts" Duration="9999999" VaryByParam="None" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Filtered SqlCacheDependency</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<asp:SqlDataSource ID="SqlDataSource1" Runat="server"

SelectCommand="SELECT [ProductID], [ProductName], [UnitsInStock] FROM [Products] WHERE CategoryID = 4"

ConnectionString="<%$ ConnectionStrings:NorthwindConnection %>">

</asp:SqlDataSource><br />

<h3>Dairy Products</h3>

<asp:GridView ID="GridView1" Runat="server" DataKeyNames="ProductID" DataSourceID="SqlDataSource1"

EmptyDataText="There are no data records to display." AutoGenerateColumns="False"

BorderWidth="1px" BackColor="White" CellPadding="4" BorderStyle="None" BorderColor="#3366CC">

<FooterStyle ForeColor="#003399" BackColor="#99CCCC"></FooterStyle>

<PagerStyle ForeColor="#003399" HorizontalAlign="Left" BackColor="#99CCCC"></PagerStyle>

<HeaderStyle ForeColor="#CCCCFF" Font-Bold="True" BackColor="#003399"></HeaderStyle>

<Columns>

<asp:BoundField ReadOnly="True" HeaderText="ProductID" DataField="ProductID" SortExpression="ProductID"></asp:BoundField>

<asp:BoundField HeaderText="ProductName" DataField="ProductName" SortExpression="ProductName"></asp:BoundField>

<asp:BoundField HeaderText="UnitsInStock" DataField="UnitsInStock" SortExpression="UnitsInStock"></asp:BoundField>

</Columns>

<SelectedRowStyle ForeColor="#CCFF99" Font-Bold="True" BackColor="#009999"></SelectedRowStyle>

<RowStyle ForeColor="#003399" BackColor="White"></RowStyle>

</asp:GridView><br />

<asp:Label ID="lblLoadTime" Runat="server" Text="Page_Load last ran at:" Width="294px"

Height="24px"></asp:Label>

</div>

</form>

</body>

</html>

13)SqlDataSourceControl.aspx.vb:

<%@ Page AutoEventWireup="false" ClassName="Filtered_aspx" CompileWith="Filtered.aspx.vb" Language="VB" %>

<%@ OutputCache SqlDependency = "NorthwindDependency:DairyProducts" Duration="9999999" VaryByParam="None" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Filtered SqlCacheDependency</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<asp:SqlDataSource ID="SqlDataSource1" Runat="server"

SelectCommand="SELECT [ProductID], [ProductName], [UnitsInStock] FROM [Products] WHERE CategoryID = 4"

ConnectionString="<%$ ConnectionStrings:NorthwindConnection %>">

</asp:SqlDataSource><br />

<h3>Dairy Products</h3>

<asp:GridView ID="GridView1" Runat="server" DataKeyNames="ProductID" DataSourceID="SqlDataSource1"

EmptyDataText="There are no data records to display." AutoGenerateColumns="False"

BorderWidth="1px" BackColor="White" CellPadding="4" BorderStyle="None" BorderColor="#3366CC">

<FooterStyle ForeColor="#003399" BackColor="#99CCCC"></FooterStyle>

<PagerStyle ForeColor="#003399" HorizontalAlign="Left" BackColor="#99CCCC"></PagerStyle>

<HeaderStyle ForeColor="#CCCCFF" Font-Bold="True" BackColor="#003399"></HeaderStyle>

<Columns>

<asp:BoundField ReadOnly="True" HeaderText="ProductID" DataField="ProductID" SortExpression="ProductID"></asp:BoundField>

<asp:BoundField HeaderText="ProductName" DataField="ProductName" SortExpression="ProductName"></asp:BoundField>

<asp:BoundField HeaderText="UnitsInStock" DataField="UnitsInStock" SortExpression="UnitsInStock"></asp:BoundField>

</Columns>

<SelectedRowStyle ForeColor="#CCFF99" Font-Bold="True" BackColor="#009999"></SelectedRowStyle>

<RowStyle ForeColor="#003399" BackColor="White"></RowStyle>

</asp:GridView><br />

<asp:Label ID="lblLoadTime" Runat="server" Text="Page_Load last ran at:" Width="294px"

Height="24px"></asp:Label>

</div>

</form>

</body>

</html>

14)Caching\StyleSheet.css

body

{

font-family: Verdana;

}

.Grid

{

font-size: 10pt;

font-family: Verdana;

}

H1

{

font-size: 24pt;

font-family: Verdana;

font-weight: bold;

}

.Button

{

font-size: 10pt;

font-family: Verdana;

}

INPUT

{

font-size: 10pt;

font-family: Verdana;

}

SELECT

{

font-size: 10pt;

font-family: Verdana;

}

15)Substitution.aspx:

<%@ Page AutoEventWireup="false" ClassName="Substitution_aspx" CompileWith="Substitution.aspx.vb" Language="VB" %>

<%@ OutputCache SqlDependency = "NorthwindDependency:Categories" Duration="9999999" VaryByParam="None" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Post-Cache Substitution</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<asp:SqlDataSource ID="SqlDataSource1" Runat="server"

SelectCommand="SELECT [CategoryID], [CategoryName], [Description] FROM [Categories]"

ConnectionString="<%$ ConnectionStrings:NorthwindConnection %>">

</asp:SqlDataSource><br />

<asp:GridView ID="GridView1" Runat="server" DataKeyNames="CategoryID" DataSourceID="SqlDataSource1"

EmptyDataText="There are no data records to display." AutoGenerateColumns="False"

BorderWidth="1px" BackColor="White" CellPadding="4" BorderStyle="None" BorderColor="#3366CC">

<FooterStyle ForeColor="#003399" BackColor="#99CCCC"></FooterStyle>

<PagerStyle ForeColor="#003399" HorizontalAlign="Left" BackColor="#99CCCC"></PagerStyle>

<HeaderStyle ForeColor="#CCCCFF" Font-Bold="True" BackColor="#003399"></HeaderStyle>

<Columns>

<asp:BoundField ReadOnly="True" HeaderText="CategoryID" DataField="CategoryID" SortExpression="CategoryID"></asp:BoundField>

<asp:BoundField HeaderText="CategoryName" DataField="CategoryName" SortExpression="CategoryName"></asp:BoundField>

<asp:BoundField HeaderText="Description" DataField="Description" SortExpression="Description"></asp:BoundField>

</Columns>

<SelectedRowStyle ForeColor="#CCFF99" Font-Bold="True" BackColor="#009999"></SelectedRowStyle>

<RowStyle ForeColor="#003399" BackColor="White"></RowStyle>

</asp:GridView><br />

<h4>

Substitution Time: <% Response.WriteSubstitution(New HttpResponseSubstitutionCallback(AddressOf CurrentTime)) %>

</h4><br />

<asp:Label ID="lblLoadTime" Runat="server" Text="Page_Load last ran at:" Width="294px"

Height="24px"></asp:Label>

</div>

</form>

</body>

</html>

16)Substitution.aspx.vb

<%@ Page AutoEventWireup="false" ClassName="Substitution_aspx" CompileWith="Substitution.aspx.vb" Language="VB" %>

<%@ OutputCache SqlDependency = "NorthwindDependency:Categories" Duration="9999999" VaryByParam="None" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>Post-Cache Substitution</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<asp:SqlDataSource ID="SqlDataSource1" Runat="server"

SelectCommand="SELECT [CategoryID], [CategoryName], [Description] FROM [Categories]"

ConnectionString="<%$ ConnectionStrings:NorthwindConnection %>">

</asp:SqlDataSource><br />

<asp:GridView ID="GridView1" Runat="server" DataKeyNames="CategoryID" DataSourceID="SqlDataSource1"

EmptyDataText="There are no data records to display." AutoGenerateColumns="False"

BorderWidth="1px" BackColor="White" CellPadding="4" BorderStyle="None" BorderColor="#3366CC">

<FooterStyle ForeColor="#003399" BackColor="#99CCCC"></FooterStyle>

<PagerStyle ForeColor="#003399" HorizontalAlign="Left" BackColor="#99CCCC"></PagerStyle>

<HeaderStyle ForeColor="#CCCCFF" Font-Bold="True" BackColor="#003399"></HeaderStyle>

<Columns>

<asp:BoundField ReadOnly="True" HeaderText="CategoryID" DataField="CategoryID" SortExpression="CategoryID"></asp:BoundField>

<asp:BoundField HeaderText="CategoryName" DataField="CategoryName" SortExpression="CategoryName"></asp:BoundField>

<asp:BoundField HeaderText="Description" DataField="Description" SortExpression="Description"></asp:BoundField>

</Columns>

<SelectedRowStyle ForeColor="#CCFF99" Font-Bold="True" BackColor="#009999"></SelectedRowStyle>

<RowStyle ForeColor="#003399" BackColor="White"></RowStyle>

</asp:GridView><br />

<h4>

Substitution Time: <% Response.WriteSubstitution(New HttpResponseSubstitutionCallback(AddressOf CurrentTime)) %>

</h4><br />

<asp:Label ID="lblLoadTime" Runat="server" Text="Page_Load last ran at:" Width="294px"

Height="24px"></asp:Label>

</div>

</form>

</body>

</html>

17)Web.config:

<?xml version="1.0"?>

<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">

<appSettings/>

 

<connectionStrings>

<add name="NorthwindConnection" connectionString="Server=localhost;Integrated Security=True;Database=Northwind" providerName="System.Data.SqlClient"/>

</connectionStrings>

 

<system.web>

<caching>

<sqlCacheDependency enabled="true" pollTime="1000">

<databases>

<add name="NorthwindDependency"

connectionStringName="NorthwindConnection"/>

</databases>

</sqlCacheDependency>

<outputCacheSettings>

<outputCacheProfiles>

<add name="ShortTime" duration="30" varyByParam="none"/>

</outputCacheProfiles>

</outputCacheSettings>

<outputCache enabled="true">

<diskCache enabled="true" maxSizePerApp="10"/>

</outputCache>

</caching>

 

<compilation debug="true"/>

<authentication mode="Windows"/>

<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">

</customErrors>

</system.web>

</configuration>

 


 

 
Fans of "The Office"
Dwight Bobbleheads are here!
  “It's me! I'm the bobblehead! Yes!”



Advertise on XMLPitstop

Advertise on XMLPitstop


EggHead Cafe
Web Servicee development
DotNetSlackers
Buy text ads here!
online storage
Color Laser Printer
Gucci sunglasses
Skype vs. sipcall
VoIP Internettelefonie
Buy text ads here!

Interested in Text ads?
2,223 Total Members
36 members(last 30 days)
8 members(last 7 days)
2 members(today)

1,609 Total Discussions
12 Posts(last 30 days)
0 Posts(last 7 days)
0 Posts(today)

17,260 Total Blog Posts
1,839 Blogs(last 30 days)
342 Blogs(last 7 days)
49 Blogs(today)

8,699 Newsgroup Posts
0 Posts(last 30 days)
0 Posts(last 7 days)
0 Posts(today)

13,786 Total Resources
5 Resources(last 30 days)
1 Resources(last 7 days)
0 Resources(today)


 

David Silverlight's XMLPitstop.com| 2801 Florida Ave #225|Miami, FL 33133|Ph:305-447-1139