0

I have the following method:

//BOLO stands for Be On The Lookout

public void LoadBolos()
{
    List<string> bolos;

    //If not loaded before
    if (ViewState["bolos"] == null)
    {
        List<string> bolos = GetBolos();

        ViewState["bolos"] = bolos;
        ViewState["index"] = 0;
    }

    else
    {
        bolos = (List<string>)ViewState["bolos"];
    }

    int index = ViewState["index"] != null ? (int)ViewState["index"] : 0;

    if (bolos.Count > 0)
    {
        imgBolo.ImageUrl = bolos[index];
        index++;
        index = index >= bolos.Count ? 0 : index;
    }

    ViewState["index"] = index;
}

I need to loop this method every 10 seconds, so I can refresh an image on the aspx page. However, I've noticed that some Thread.Timer functions don't allow non-static functions to be used.

If I convert this method to static, I can no longer access private variables that load on page load, nor can I use the Viewstate nor access the image.

So I was wondering which would be the most accurate way to refresh an image on the page every 10 seconds.

2
  • you need to do this in javascript. every 10 seconds, poll the server for a refreshed image.
    – ps2goat
    Feb 8, 2016 at 19:48
  • Yeah, I actually tried that option first, I guess I'll have to re do the post now focusing on js
    – Victor
    Feb 8, 2016 at 19:57

1 Answer 1

-2

You can refresh the page using the html content using Untitled Page

<meta http-equiv="refresh" content="20"  />

2
  • For every 10 secs <head runat="server"> <title>Untitled Page</title> <meta http-equiv="refresh" content="10" /> </head>
    – Maheswari
    Feb 8, 2016 at 20:03
  • this is not good, as it refreshes the entire page. browsers can ignore this, as well.
    – ps2goat
    Feb 8, 2016 at 22:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.