This post is a step enhance version of my previous post: Preventing Multiple Button Click on Asp.net Page
Problem: How to disable button immediately on user click in asp.net so that user cannot click multiple time.
Solution: To solve this problem use regular html button, including runat=”server” attribute and write the disable client-side click event which disable button immediately and server-side event which runs the actual code for click event.
Client-Side Event to disable button immediately.
var objName = 'Button1';
msg = 'Please Wait...('+ c +')!';
Note: Replace “Button1” with object name of button control
And following button code in body.
Button Control – HTML Button instead of Asp button.
value="Submit Payment" name="Button1"
Server-Side Event to perform actual task
This task can be any as per your logic, for an example I am performing some heavy time consuming task, you can even make use of Threading concept to minimize code…
protected void Button1_Click(object sender, EventArgs e)
ArrayList a = new ArrayList();
for (int i = 0; i < 10000; i++)
for (int j = 0; j < 1000; j++)
a.Add(i.ToString() + j.ToString());
Response.Write("I am done: " +
Before Button Click
During Button Click
After Task is done