hide that button after it is clicked once and successfully request sent to server. and after the response comes back from server. you may show it to the user again.
Like other members suggested, you should consider a client-side script based approach to prevent the service request be invoked for multiple times.
For example, if you're using a button to trigger the AJAX websevice call, then you can declare a global script variable which indicate whether the AJAX service call is inprogress. And you will set the variable to true before the AJAX call starts, and reset
it to false after the AJAX call's complete callback handler is executed.
var isSvcCallInProgress = false;
function onButtonClick(){
if(isSvcCallInProgress == true) return;
isSvcCallInProgress == true;
// Do Ajax service call here (and don't forget to reset the isSvcCallInProgress variable to false in the complete callback no matter succeed or fail)
}
mbs220
Member
7 Points
15 Posts
how can i prevent any Web Requast until finishing my last request ?
Apr 19, 2012 10:16 AM|LINK
hi there...
i want to response to Just one request on each requst
means i send a request to server... IMMEDIATE i send (click on same btn ) a request again...
how can i prevent it ? (is it possible via HttpHandler ? if yes HOW ?)
i see it in a Bank Site
when i click on show Credite , and click again on it , site shows me a warning : your last request's not finished yet
please help me
webrequest httphandler
Ken Tucker
All-Star
16797 Points
2608 Posts
MVP
Re: how can i prevent any Web Requast until finishing my last request ?
Apr 19, 2012 10:33 AM|LINK
I have used the jquery plug in blockui to prevent a user from submitting any more requests until the current one finishes
http://archive.plugins.jquery.com/project/blockUI
Space Coast .Net User Group
sean freeman
Member
170 Points
96 Posts
Re: how can i prevent any Web Requast until finishing my last request ?
Apr 20, 2012 03:57 PM|LINK
hi,
hide that button after it is clicked once and successfully request sent to server. and after the response comes back from server. you may show it to the user again.
webrequest httphandler
Akter-Uddin
Member
88 Points
49 Posts
Re: how can i prevent any Web Requast until finishing my last request ?
Apr 21, 2012 02:13 PM|LINK
Suppose your button name is "btnSave". Then use this code into codebehind PageLoad
btnSave.Attributes.Add("onclick", " this.disabled = true; " + ClientScript.GetPostBackEventReference(btnSave, null) + ";");There are also a lot of way to do this.....
Chittagong, Bangladesh.
---------------------------------------------------------------------------
Nothing is permanent in this world...not even your problems.
Steven Cheng...
Contributor
4199 Points
548 Posts
Microsoft
Moderator
Re: how can i prevent any Web Requast until finishing my last request ?
Apr 23, 2012 03:22 AM|LINK
Hi mbs220,
Like other members suggested, you should consider a client-side script based approach to prevent the service request be invoked for multiple times.
For example, if you're using a button to trigger the AJAX websevice call, then you can declare a global script variable which indicate whether the AJAX service call is inprogress. And you will set the variable to true before the AJAX call starts, and reset it to false after the AJAX call's complete callback handler is executed.
var isSvcCallInProgress = false; function onButtonClick(){ if(isSvcCallInProgress == true) return; isSvcCallInProgress == true; // Do Ajax service call here (and don't forget to reset the isSvcCallInProgress variable to false in the complete callback no matter succeed or fail) }Feedback to us
Microsoft One Code Framework