How to disable button that causes postback in ASP.net
April 30th, 2009
You can disable a button on the client side to prevent multiple clicks by just adding an onClick function that runs on client side. You should check if page has a client side validation script and it passes first. If so, you just disable the button and call postback event.
Here is an example for the button named “btnAddcustomer”. Just paste it into Page_Load.
1 2 | Dim strDisable As String = "if (typeof(Page_ClientValidate) == 'function') {if (Page_ClientValidate() == false) { return false; }} this.value = 'Please wait...'; this.disabled = true; " & ClientScript.GetPostBackEventReference(btnAddCustomer, "") btnAddCustomer.Attributes.Add("onclick", strDisable) |













Burc Sade (aka laforge) is a full time application developer (mainly web applications), part time entrepreneur located in Istanbul, Turkey. This site is his blog about the projects going on, little programming tricks, Internet, travel, photography and other bits and pieces.