I have a Save button on a web page.
I want to disable the button when clicked, so that the user does not click it more than once, as the serevr side code is being processed.
i disabled the button by calling a javascript function -
btnSave.Attributes.Add("onClick","return buttonDisabled();") ;
In the Javascript file i have -
function disableButton()
{
var btnSave = document.getElementById('btnSave') ;
btnSave.disabled = true ;
return true ;
}
since the button gets disabled my server side code(in C#) does not get executed.
thanks a lot for any kind of help
Your button:
<input type = submit id = "btnSave" onclick = "disableButton()">
The Javascript function:
function disableButton() {
var btnSave = document.getElementById('btnSave') ;
btnSave.disabled = true ;
yourformname.submit();
}
I hope this solves your problem.
Here's an entertaining article with a step-by-step explanation of the one-click only functionality especially for ASP.NET:
http://blog.webonweboff.com/2010/04/...once-only.html
Click button once only
Hope this helps
because it is a ASP.NET application.do write the client script under OnClientClick. then double click the button to write asp.net code for it it would look something of this sort
Code:<asp:Button id="btn1" text="Submit" onClientClick="this.visible=false" onClick="btn1_Click()" runat="server"/>
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks