By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,665 Members | 1,229 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,665 IT Pros & Developers. It's quick & easy.

How to force a reload of cached user control?

P: n/a
I create a user control that is used as a page header for all
application's pages. The user control contains a HyperLink control named
accountHyperlink whose text can either set to "Account/Logon" or
"Account/Logout" depending on whether the user is logged on. I want to cache
this user control for 1 hour but have it automatically reloaded if the
accountHyperlink.Text is changed. So I place the following line of code on
its ascx page:

<% @OutputCache%@ OutputCache Duration="3600" VaryByParam="none"
VaryByControl="accountHyperlink" %>

The user control is not refreshed on other pages that use it after the
accountHyperlink.Text changed. So do I use incorrect codes for my purpose or
do I need to place more codes (somewhere) to force the user control to
reload to reflect the change?

Nov 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Edward,
Is it possible to just have the item change it's text based on the logged in
status of the user? By using a cache, you are leaving a lot of work to
unknown possibilities. The cache could be overwritten because it ran out of
space and needed the cache room for something else. Also, the cache could be
reset elsewhere, either in code, or by an application restart. Generally, I
only use the cache for storing items that I can 1) always recreate and 2) do
not care about the state of the cached entry.
If you cannot recreate the control, then what happens when the cache
expires? It COULD expire before the 3600 minutes remember.

HTH

Steve
"Edward Chung" <ed******@3web.net> wrote in message
news:eQ**************@TK2MSFTNGP09.phx.gbl...
I create a user control that is used as a page header for all
application's pages. The user control contains a HyperLink control named
accountHyperlink whose text can either set to "Account/Logon" or
"Account/Logout" depending on whether the user is logged on. I want to cache this user control for 1 hour but have it automatically reloaded if the
accountHyperlink.Text is changed. So I place the following line of code on
its ascx page:

<% @OutputCache%@ OutputCache Duration="3600" VaryByParam="none"
VaryByControl="accountHyperlink" %>

The user control is not refreshed on other pages that use it after the
accountHyperlink.Text changed. So do I use incorrect codes for my purpose or do I need to place more codes (somewhere) to force the user control to
reload to reflect the change?

Nov 19 '05 #2

P: n/a
Edward Chung wrote:
I create a user control that is used as a page header for all
application's pages. The user control contains a HyperLink control named accountHyperlink whose text can either set to "Account/Logon" or
"Account/Logout" depending on whether the user is logged on. I want to cache this user control for 1 hour but have it automatically reloaded if the accountHyperlink.Text is changed. So I place the following line of code on its ascx page:

<% @OutputCache%@ OutputCache Duration="3600" VaryByParam="none"
VaryByControl="accountHyperlink" %>

The user control is not refreshed on other pages that use it after the accountHyperlink.Text changed. So do I use incorrect codes for my purpose or do I need to place more codes (somewhere) to force the user control to reload to reflect the change?


http://www.dotnet247.com/247referenc.../11/59941.aspx

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.