Delay page processing for some seconds
I am using ASP.NET 4.0 .I have a ajax timer control on master page which is continue running, on my content page i have 3 text box control and a submit button. i want to delay the page processing for 20 second whenever anybody click on submit button but timer should not stop it should keep running. how to do thi开发者_运维知识库s ?
You have to set Timer1.Enabled = false;
in finally block
protected void Timer1_Tick(object sender, EventArgs e)
{
try
{
// your code ............
}
catch
{
}
finally
{
divLoading.Visible = false;
Timer1.Enabled = false;
}
}
I'm a little unclear on what you need here - but what I think you're asking for is you'd like a button to be clicked on the client side, have a 20 second wait period on the client side while your timer is still running, then submit the page for processing. If this is what you want it has to be fully client driven - the timer isn't "running" in the server code. This is all based on the assumption that you're talking about an AJAX timer...
If this is what you're asking for, the following code should get you there:
function onButtonClick(e) {
var evt = Sys.UI.DomEvent.isInstanceOfType(e) ? e : new Sys.UI.DomEvent(e);
if(evt.target["_doClick"] === true) {
// just let the event happen
// (still w/ button disabled to prevent double click)
evt.target["disabled"] = "disabled";
evt.target["_doClick"] = false;
alert('the real click');
} else {
evt.target["disabled"] = "disabled";
evt.target["_doClick"] = true;
evt.preventDefault();
evt.stopPropagation();
var t = evt.target;
setTimeout(function () { t["disabled"] = ""; t.click(); }, 20000);
}
}
精彩评论