468,720 Members | 1,647 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,720 developers. It's quick & easy.

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 5659
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 discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.