Click here to Skip to main content
16,004,602 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
See more:
Hi,

I Have 2 buttons. On clicking on 1st button, button click event will get triggered. On clicking on 2nd button 1st button's triggered event should get stopped. How to do that?

Regards, Kiruba
Posted
Comments
Sergey Alexandrovich Kryukov 6-Aug-14 14:06pm    
What have you tried so far?
—SA
kirubakaran3@yahoo.co.in 6-Aug-14 14:09pm    
On Button1 click we are making database call. If we want to cancel that call, have to click on Button2. In turn it should stop the Database call triggered by Button1.
Sergey Alexandrovich Kryukov 6-Aug-14 14:26pm    
I doubt it's possible. The database statements are transactional, they have to be complete.
—SA
Dilan Shaminda 6-Aug-14 14:07pm    
what you are doing inside ButtonClick1 and ButtonClick2?
kirubakaran3@yahoo.co.in 6-Aug-14 14:09pm    
On Button1 click we are making database call. If we want to cancel that call, have to click on Button2. In turn it should stop the Database call triggered by Button1.

1 solution

This won't be handle able using ASP.NET because ASP.NET doesn't work with such task.

To cancel the event handler you can here use the C# Thread. Which will execute if the button2 is not clicked, and will stop if you click on the button2.

C# threads are very helpfull if you're working with data that depends on the state of some other process. This way you can handle the UI seperately and the business logic will be handled seperately.

So the short answer will be, to create a class inside the App_Code folder and then use the Thread in that file, and create the function to trigger the Thread and if the second button is clicked stop the thread.

http://msdn.microsoft.com/en-us/library/system.threading.thread(v=vs.110).aspx[^]
 
Share this answer
 

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