473,327 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

timer to delay execution of event

Lets say I want a button to execute 10 seconds after I press it, not
immediately.
Any ideas how to cause that, in a code-behind. IMO its only server side
code, I don't think javascript needs to get in to the equation (?)
Nov 19 '05 #1
8 5859
you cant do it in codebehind, it would have to be a clientside delay. You
COULD, have the button fire but "wait" (n) seconds before it does something,
but why? I mean what is it you need to get at that needs the delay?

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Jason Shohet" <__******@yahoo.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Lets say I want a button to execute 10 seconds after I press it, not
immediately.
Any ideas how to cause that, in a code-behind. IMO its only server side
code, I don't think javascript needs to get in to the equation (?)

Nov 19 '05 #2
I just want to see if it actually works, I'm tinkering. I used it once to
cause a screen refresh w/o a postback. Now I'm trying to see if I can
postpone execution w/ a js func, then have it return to do the rest of the
code. ie:

in page load: this.button8.Attributes.Add("onclick", pr()");

in button8_Click: Response.Write("hi, did this not appear right away?");

in the aspx: <script>
function pr() {
window.setTimeout("pr()", 100);
}
<script>

Alas, it doesn't seem to work. The message appears right away. I figured
the js timer would delay execution on the Response.Write...?
Nov 19 '05 #3
You are mixing client and server events up....
You can delay the POST to the server, or you can delay the execution within
the code-behind from within it, but you can't have any interaction between
the two while this is happening.

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Jason Shohet" <__******@yahoo.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I just want to see if it actually works, I'm tinkering. I used it once to
cause a screen refresh w/o a postback. Now I'm trying to see if I can
postpone execution w/ a js func, then have it return to do the rest of the
code. ie:

in page load: this.button8.Attributes.Add("onclick", pr()");

in button8_Click: Response.Write("hi, did this not appear right
away?");

in the aspx: <script>
function pr() {
window.setTimeout("pr()", 100);
}
<script>

Alas, it doesn't seem to work. The message appears right away. I
figured the js timer would delay execution on the Response.Write...?

Nov 19 '05 #4
ok i see.... Alright, then I know how to delay the POST to the server from
b4.
What I'm not sure is the 2nd scenario, the code to delay the execution of
the c.behind from within the c.behind?
Nov 19 '05 #5
It will be tricky... but traditionally you call the form.submit() in the
timer-delay. In this case though you will have to have it fire the
individual buttons click, unless you can use the page_load and IsPostBack()

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Jason Shohet" <__******@yahoo.com> wrote in message
news:Of**************@TK2MSFTNGP09.phx.gbl...
ok i see.... Alright, then I know how to delay the POST to the server
from b4.
What I'm not sure is the 2nd scenario, the code to delay the execution of
the c.behind from within the c.behind?

Nov 19 '05 #6
TY, I'm going to look up timer-delay syntax in c#, and also ask around on
the c# ng.
if it seems way to difficult i'll give up, its more of a curiosity to see if
it can be done
Nov 19 '05 #7
actually i think just Thread.Sleep (1000) does it :)
Nov 19 '05 #8
It is tough.... you are basically trying to put the thread/process to sleep
(search on "sleep"). There is realy no need to ever do this, or rather
shouldnt be. It's like pausing lifesupport.....

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Jason Shohet" <__******@yahoo.com> wrote in message
news:Og**************@TK2MSFTNGP10.phx.gbl...
TY, I'm going to look up timer-delay syntax in c#, and also ask around on
the c# ng.
if it seems way to difficult i'll give up, its more of a curiosity to see
if it can be done

Nov 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: ELO | last post by:
Hi all Every week, I need to get two files on a remote server. I have developped a C# Windows Service with two System.Threading.Timer to do this task For the first one, the delay (TimeSpan...
4
by: vinay | last post by:
Hi, I need to use a Timer at run time. I have created a Timer class which has method 'CreateTimer'. I am able to create a timer and run the associated event (code snippet follows), but I am...
4
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I make a 10 second delay? ----------------------------------------------------------------------- There...
19
by: UG | last post by:
I just wanted to know whether any timer facility exists in C, as it is not mentioned in K&R 2, or in the ISO Draft. By timer function i mean that when we use standard input function like scanf() or...
3
by: =?Utf-8?B?RGF2ZQ==?= | last post by:
I am trying to use the timer to make a login form show after a specified interval. However, if the interval is set to a value greater than 5000 nanosecond, then it does not respond. What could be...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.