×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

AutoRefresh with condition

AutoRefresh with condition

AutoRefresh with condition

(OP)
Hi Guys,

I have had function for the grid which returning the value of database which determines whether the job is currently running.

I would like to add into the function if the job is currently running I would like to do auto refresh every 5 seconds.

I have searched in google, there is no specifically like this and We dont want to use Ajax time control as we would like to make it simple and refresh the whole page.

Could you guys shed me some light for this?
Any input will be appreciated.

Thanks in advance guys,

RE: AutoRefresh with condition

are you talking about the web? if so then this is a client side issue, not a server issue. remember once the request is sent from the server to the client the server forgets about what just happened.

you will need a javascript timer to instruct the page to refresh. there may also be some html meta-data tags you can include to instruct the browser to refresh the page.

Quote:

We dont want to use Ajax time control as we would like to make it simple and refresh the whole page.
ajax is actually very simple with libraries like jquery, jquery-tmpl and backbone. you also get full control over rendering which you may need when the client/users come back and say "it works, but can it happen like this instead?"

Jason Meckley
Programmer

FAQ855-7190: Database Connection Management
FAQ732-7259: Keeping the UI responsive

RE: AutoRefresh with condition

Have a non-programming solution (sorta)

Firefox has a free addin for page refreshing.
As long as you're okay with both Firefox, and the page refreshing regardless of the job status, it's a quick and dirty way to get a HUD to show correct values.

Otherwise you're stuck writing client side code. You can invalidate the page state server side, but that's not going to cause a delayed round trip.

Lod

You've got questions and source code. We want both!

RE: AutoRefresh with condition

(OP)
Hi Guys,

Thanks for the info,
at the moment I have used the javascript code chucked into the c# server code like this

CODE

if(the job is running)
{
Page.ClientScript.RegisterStartupScript(GetType(), "refresh", "window.setTimeout('var url = window.location.href; window.location.href = url',5000);", true);
}

As you can see the code above is refresh every 5 seconds.
Between the job 1 and 2 there is a gap up to 30 seconds to wait.

How do I create the code for this:

-wait 30 seconds
-refresh the page once.

Both codes above to initiate refresh page for the next job.
Thanks guys,
 

RE: AutoRefresh with condition

Sometimes my best work comes from not doing anything :)

peac3, you're going to need to add an else condition. change your timeout from (5)000 to (30)000.

If you only want a single refresh then you're going to have to store something in session to indicate how many times you have refreshed the page. Keep in mind you're going to want to add a bit to clear that value if a job is running.

Lod

PS: too bad you can't move a thread...

You've got questions and source code. We want both!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close