Preventing Multiple Button Click on Asp.net Page
To perform this task add javascript function.
Client-Side Event to disable button immediately.
<head runat="server">
<script language = "javascript">
var c=0;
function DisableClick()
{
var objName = 'Button1';
document.getElementById(objName).disabled=true;
c=c+1;
msg = 'Please Wait...('+ c +')!';
document.getElementById(objName).value= msg;
var t=setTimeout('DisableClick()',1000);
}
</script>
</head>
And following button code in body.
<INPUT id="Button1" onclick="DisableClick();" type="button" value="Submit Payment" name="Button1" runat="server" onserverclick="Button1_Click">
Server-Side Event to perform actual task
This task
can be any as per your logic:
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: " +
DateTime.Now.ToLongTimeString());
}
Thanks
Sreenath
Revision number 1, Wednesday, February 17, 2010 3:31:44 PM by sreenatht
This is not the most up to date version of this article. The most recent version can be found here.
You must Login to comment.
|
Fri, Feb 19, 2010 12:30 AM
by thirumurugan.ga
|
Is it possible enable button automatically after server response without set timeout in javascript?
|
|
Thu, Oct 7, 2010 7:01 AM
by munihemadribabu.jogi
|
Can we user like below Button1.attributes.add("disabled","false");
|
|
Fri, May 27, 2011 10:10 AM
by dvd.ribeiro
|
How can you achieve this by using ImageButton without resulting in double postback?
|