refresh image in asp.net page

Discussion in 'ASP .Net' started by =?Utf-8?B?cmFtZW5kcmE=?=, Dec 1, 2005.

  1. how to refresh a image control to pick up the latest image file on a asp.net
    page. i am generating a image based on the input from the user and displaying
    it on the page through image control. The problem is that i am not able to
    get the latest image on the page, it keeps showing the old page. But when i
    hit the refresh button on the toolbar it correctly gets the latest image and
    displays it in the control. But that has another problem, it pops up a dialog
    asking user whether he wants to retry or cancel...

    so in short i need to implement some logic so that the image control is
    refreshed when the image changes (i know exactly when the image changes) and
    dont popup any dialog box for user input.

    any help is greatly appreciated

    thanks, Ramendra
    =?Utf-8?B?cmFtZW5kcmE=?=, Dec 1, 2005
    #1
    1. Advertising

  2. You can trick the browser into reloading the image from the server by adding
    a random query parameter to the image url. I am using a javascript call that
    produces the millisecond part of the current time.

    Eliyahu

    "ramendra" <> wrote in message
    news:...
    > how to refresh a image control to pick up the latest image file on a
    > asp.net
    > page. i am generating a image based on the input from the user and
    > displaying
    > it on the page through image control. The problem is that i am not able to
    > get the latest image on the page, it keeps showing the old page. But when
    > i
    > hit the refresh button on the toolbar it correctly gets the latest image
    > and
    > displays it in the control. But that has another problem, it pops up a
    > dialog
    > asking user whether he wants to retry or cancel...
    >
    > so in short i need to implement some logic so that the image control is
    > refreshed when the image changes (i know exactly when the image changes)
    > and
    > dont popup any dialog box for user input.
    >
    > any help is greatly appreciated
    >
    > thanks, Ramendra
    Eliyahu Goldin, Dec 1, 2005
    #2
    1. Advertising

  3. =?Utf-8?B?cmFtZW5kcmE=?=

    Joerg Jooss Guest

    Eliyahu Goldin wrote:

    > You can trick the browser into reloading the image from the server by
    > adding a random query parameter to the image url. I am using a
    > javascript call that produces the millisecond part of the current
    > time.


    Or unleash the full power of HTTP by sending a Cache-Control: no-cache
    header ;-)

    Cheers,
    --
    http://www.joergjooss.de
    mailto:
    Joerg Jooss, Dec 1, 2005
    #3
  4. Hi Eliyahu,

    I have added the query string parameter (page.aspx?a=test) to the image url
    but still the image doesn;t seem to get refreshed with the new one.

    please clarify you suggestion.

    thanks, Ramendra

    "Eliyahu Goldin" wrote:

    > You can trick the browser into reloading the image from the server by adding
    > a random query parameter to the image url. I am using a javascript call that
    > produces the millisecond part of the current time.
    >
    > Eliyahu
    >
    > "ramendra" <> wrote in message
    > news:...
    > > how to refresh a image control to pick up the latest image file on a
    > > asp.net
    > > page. i am generating a image based on the input from the user and
    > > displaying
    > > it on the page through image control. The problem is that i am not able to
    > > get the latest image on the page, it keeps showing the old page. But when
    > > i
    > > hit the refresh button on the toolbar it correctly gets the latest image
    > > and
    > > displays it in the control. But that has another problem, it pops up a
    > > dialog
    > > asking user whether he wants to retry or cancel...
    > >
    > > so in short i need to implement some logic so that the image control is
    > > refreshed when the image changes (i know exactly when the image changes)
    > > and
    > > dont popup any dialog box for user input.
    > >
    > > any help is greatly appreciated
    > >
    > > thanks, Ramendra

    >
    >
    >
    =?Utf-8?B?cmFtZW5kcmE=?=, Dec 2, 2005
    #4
  5. I am new to Asp.net and therefore i am not able to understand your suggestion
    or i am doing it in wrong way.

    -RK

    "Eliyahu Goldin" wrote:

    > You can trick the browser into reloading the image from the server by adding
    > a random query parameter to the image url. I am using a javascript call that
    > produces the millisecond part of the current time.
    >
    > Eliyahu
    >
    > "ramendra" <> wrote in message
    > news:...
    > > how to refresh a image control to pick up the latest image file on a
    > > asp.net
    > > page. i am generating a image based on the input from the user and
    > > displaying
    > > it on the page through image control. The problem is that i am not able to
    > > get the latest image on the page, it keeps showing the old page. But when
    > > i
    > > hit the refresh button on the toolbar it correctly gets the latest image
    > > and
    > > displays it in the control. But that has another problem, it pops up a
    > > dialog
    > > asking user whether he wants to retry or cancel...
    > >
    > > so in short i need to implement some logic so that the image control is
    > > refreshed when the image changes (i know exactly when the image changes)
    > > and
    > > dont popup any dialog box for user input.
    > >
    > > any help is greatly appreciated
    > >
    > > thanks, Ramendra

    >
    >
    >
    =?Utf-8?B?cmFtZW5kcmE=?=, Dec 2, 2005
    #5
  6. Hi Eliyahu,

    thanks a lot it solved my problem.

    thanks, Ramendra

    "Eliyahu Goldin" wrote:

    > You can trick the browser into reloading the image from the server by adding
    > a random query parameter to the image url. I am using a javascript call that
    > produces the millisecond part of the current time.
    >
    > Eliyahu
    >
    > "ramendra" <> wrote in message
    > news:...
    > > how to refresh a image control to pick up the latest image file on a
    > > asp.net
    > > page. i am generating a image based on the input from the user and
    > > displaying
    > > it on the page through image control. The problem is that i am not able to
    > > get the latest image on the page, it keeps showing the old page. But when
    > > i
    > > hit the refresh button on the toolbar it correctly gets the latest image
    > > and
    > > displays it in the control. But that has another problem, it pops up a
    > > dialog
    > > asking user whether he wants to retry or cancel...
    > >
    > > so in short i need to implement some logic so that the image control is
    > > refreshed when the image changes (i know exactly when the image changes)
    > > and
    > > dont popup any dialog box for user input.
    > >
    > > any help is greatly appreciated
    > >
    > > thanks, Ramendra

    >
    >
    >
    =?Utf-8?B?cmFtZW5kcmE=?=, Dec 2, 2005
    #6
  7. =?Utf-8?B?cmFtZW5kcmE=?=

    alexstephens

    Joined:
    Dec 22, 2007
    Messages:
    1
    refresh image

    I think what is meant is that the actual image url i.e "www.yoursite.com/images/myImage.jpg" should be appended with something like "www.yoursite.com/images/myImage.jpg?uygwefug=1"

    Basically the browser is seeing the same image so returns it from cache so by adding random text on the end your forcing the browser to retrive the new image.

    I have had to do this myself and it worked well, the only thing to watch for is if testing to see if the image actually exists first, it will fail if you have params on it.
    alexstephens, Dec 22, 2007
    #7
  8. =?Utf-8?B?cmFtZW5kcmE=?=

    edy tang

    Joined:
    Oct 5, 2009
    Messages:
    1
    Refresh image each time

    If you add the current time to the link, the link will be unique each time "myImage.jpg?myTime=" & now(). So, it will be refreshed each time.
    Last edited: Oct 5, 2009
    edy tang, Oct 5, 2009
    #8
    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. brian lanning
    Replies:
    0
    Views:
    592
    brian lanning
    Jul 29, 2003
  2. =?Utf-8?B?cmFtZW5kcmE=?=

    refresh image in asp.net page

    =?Utf-8?B?cmFtZW5kcmE=?=, Dec 1, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    624
    =?Utf-8?B?cmFtZW5kcmE=?=
    Dec 1, 2005
  3. Per Magnus L?vold
    Replies:
    1
    Views:
    5,117
    John C. Bollinger
    Oct 8, 2004
  4. =?Utf-8?B?TWlybw==?=

    Refresh image in asp:Image-control

    =?Utf-8?B?TWlybw==?=, Feb 27, 2007, in forum: ASP .Net
    Replies:
    6
    Views:
    788
    Joerg Jooss
    Feb 27, 2007
  5. Pkenty
    Replies:
    0
    Views:
    389
    Pkenty
    May 28, 2004
Loading...

Share This Page