setty
Joined: 01 Apr 2009 Posts: 127 Location: GOLLAPROLU
|
Posted: Fri Feb 26, 2010 6:52 am Post subject: |
|
|
Hi suraj,
* ASP.NET provides a mechanism for caching portions of pages, called page fragment caching.
* To cache a portion of a page, you must first encapsulate the portion of the page you want to cache into a user control.
* In the user control source file, add an OutputCache directive specifying the Duration and VaryByParam attributes.
* When that user control is loaded into a page at runtime, it is cached, and all subsequent pages that reference that same user control will retrieve it from the cache.
* Here I have user caching on user control, so when ever we used in a page , only partial page will be cached.
Sample Example:
<!— UserControl.ascx —>
<%@ OutputCache Duration='60'
VaryByParam='none' %>
<%@ Control Language="'C#'" %>
<script runat="server">
protected void Page_Load(Object src, EventArgs e)
{
lblDate.Text = "User control generated at " +
DateTime.Now.ToString();
}
</script>
<asp:Label id='lblDate' runat="'server'" /> _________________ Thanks & Regards
D.B.G.Setty
Software Engineer
NYROS TECHNOLOGIES |
|