Click here to Skip to main content
15,884,725 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have an Webseite with a time-consuming search function.
currently it is porsible to start multiple search requests.

for example:
the user clicks a row 10 times on the serch button... but, the first search is not finisht... the other 9 searches are in the pipe...
now the server serch 10 times successively.

How can I prevent it?

thx,
benny
Posted

You could set the search button's Enabled property to false at the beginning of the search process, then set it back to true when the search is completed...assuming your using a PostBack to start the search.
 
Share this answer
 
Comments
fjdiewornncalwe 11-May-11 9:20am    
Right idea, but with a long running process, the OP may wish to use Javascript to intercept the submission to disable the submit button on the client-side, then send the postback. A postback to the server won't update the button state until after the postback is complete.
GenJerDan 11-May-11 9:24am    
Yeah, you're right. That's what I get for looking at these first thing in the morning... Yo, BoySetsFire: ignore my answer.
senguptaamlan 11-May-11 9:25am    
use ASP.NET Callback or XMLHttpRequest instead
This was my setup that managed a similar situation:

1. After click on button that is supposed to start the action that button is disabled first thing! (javascript side)
2. Same click starts (lengthy export) process on web server via AJAX call.
3.1 Webserver responds with data that indicates that the process was started. -> button stays disabled and a periodical polling is setup (see. point 4.)
3.2 Webserver responds with data that indicates failure in start of process -> UI notification and button is enabled again
4.1 In case of 3.1 periodically check if the process on the server has finished.
4.2 When finished show result

When displaying the page (postback or not) make sure that the button is only enabled if the current user does not have a search process currently running.

If you have any doubts left feel free to leave me a comment.

Best Regards,

-MRB
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900