I have a page where when some operation goes wrong i want to start the timer, wait 30 second, stop the timer and retry the operation. Every time the timer starts I need to inform the user about it by changing some label’s text.
How can I do it?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If I understand correctly, the I think you should use a client-side (javascript) timer instead. You can not use a server-side timer for this.
When you detect the error-condition, you update the label accordingly and display it to the user. At the same time you invoke a client-side timer which will postback after 30 seconds.
E.g. put the following timer-code onto your page:
In case of the error-condition, you have to make sure that the client-side timer will be started:
I hope this helps (the code is not tested, since I don’t have visual studio available right now).
Update:
To ‘simulate’ a button click, you have to pass to button’s client id to the __doPostBack() method, e.g:
For some other possibilities, see the following question/answer: