Please check the below code regading Caching?

Posted by Naga116 under ASP.NET on 8/11/2011 | Points: 10 | Views : 1033 | Status : [Member] | Replies : 2
I need help regarding Caching?

I am having a Texbox control, that should be caching.
and another one is label control display the system time.
One control in Caching and another one non caching. How to chcek it is working or not?
I tried below code but that i was not understood..

.aspx Source code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Cachingimpl.aspx.cs" Inherits="Cachingimpl" %>
<%@ OutputCache Duration="60" VaryByControl="TextBox1" %>

<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Label ID="lbl" runat="server" ></asp:Label>


Code Behind
Page Load Evenets
TextBox1.Text = "Naga";
lbl.Text = System.DateTime.Now.ToString();

--> 1. Text Box data will fetch from the Cache
2.Label time should always change between 60 seconds.

But here Label also going cache without using caching.
Can you please explain me?



Posted by: Hmanjarawala on: 8/11/2011 [Member] Bronze | Points: 25


As per my concept, in caching it jst check whether value of control is changed or not....

means in your cache if value of textbox is changed then page is again processed by .Net engines....
but if textbox value are not changed it will generate output from cache.

Hope you understood what i means....

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere

Naga116, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Dhirendra on: 8/11/2011 [Member] Starter | Points: 25

VaryByControl means that the list of controls which specified in the VaryByControl parameter has changed then in that case only the will refresh the cache for that page( or part of page ) if the parameters which are not mentioned in the VaryByControl are modified then asp page will retune that page from cache.

However you tried to catch something... thats good..

Naga116, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response