How to force a reload of cached user control?

Discussion in 'ASP .Net' started by Edward Chung, Feb 13, 2005.

  1. Edward Chung

    Edward Chung Guest

    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?
     
    Edward Chung, Feb 13, 2005
    #1
    1. Advertising

  2. Edward Chung

    Steve Lutz Guest

    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" <> wrote in message
    news:...
    > 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?
    >
    >
    >
     
    Steve Lutz, Feb 13, 2005
    #2
    1. Advertising

  3. Edward Chung

    Aquila Deus Guest

    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/247reference/msgs/11/59941.aspx
     
    Aquila Deus, Feb 13, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Craig G
    Replies:
    0
    Views:
    402
    Craig G
    Mar 7, 2005
  2. =?Utf-8?B?bG9uZG9uIGNhbGxpbmc=?=

    force asp.net to remove cached page literals asp.net 1.1

    =?Utf-8?B?bG9uZG9uIGNhbGxpbmc=?=, Jul 4, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    557
    =?Utf-8?B?bG9uZG9uIGNhbGxpbmc=?=
    Jul 5, 2005
  3. Joshua Beall
    Replies:
    26
    Views:
    222,729
    AndreiKaa
    Jun 29, 2007
  4. gen_tricomi
    Replies:
    2
    Views:
    787
    gen_tricomi
    May 23, 2006
  5. Lasse Reichstein Nielsen

    Force reload after user changes browser size

    Lasse Reichstein Nielsen, Oct 15, 2003, in forum: Javascript
    Replies:
    3
    Views:
    167
    Thomas 'PointedEars' Lahn
    Nov 6, 2003
Loading...

Share This Page