aspdotnet-suresh offers articles and tutorials,csharp dot net, articles and tutorials,VB.NET Articles,Gridview articles,code examples of 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

How to disable button after click or during postback and how to change button text after click or during postback in

Nov 25, 2010

Here I will explain how to disable button after click or during postback and I will explain how to change the button text after click on button or during postback in


In many websites we will see disable of button after click on that for getting some content how we can implement that in our application.

Here we need to observe one point that is how we can findout button click and how we can disable button and how we can change text of button during postbacks in Here we have chance to get postsbacks by using these statements


Here I will explain what the each statement is


This Statement Manages partial-page updates of server updatepanel controls in the browser, and defines properties, events, and methods that can be used to customize a Web page by using client script.


This statement Raised before processing of an asynchronous postback starts and the postback request is sent to the server.


This Raised after an asynchronous postback is finished and control has been returned to the browser.

After that design your aspx page like this 

<html xmlns="" >
<head id="Head1" runat="server">
<title>Disable Button and Change Text of button</title>
<form id="form1" runat="server">
<asp:ScriptManager ID="sc" runat="server" EnablePartialRendering="true">
<script type="text/javascript">
function BeginRequestHandler(sender, args) {
document.getElementById('<%= lblMessage.ClientID %>').innerText = "Processing...";
document.getElementById('<%= btnSubmit.ClientID %>').innerText = "Processing";
args.get_postBackElement().disabled = true;
<asp:UpdatePanel ID="updpnlSubmit" runat="server">
<asp:Button ID="btnSubmit" Text="Submit" runat="server" OnClick="btnSubmit_Click" />
<asp:Label ID="lblMessage" runat="server"></asp:Label>

In code behind button click write like this

protected void btnSubmit_Click(object sender, EventArgs e)
lblMessage.Text = "PostBack completed!!";


Other related post

how to show progressbar during postback in

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest,, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email


zia said...

great tutorials for beginners. althought i know most of the techniques . i have still bookmarked ur site and added your rss feed on google reader for quick reference

zia said...

try posting some advanced tuts bro

Suresh Dasari said...

Thanks Zia sure i will learn and post advanced topics

K@rTh!K said...

Microsoft Jscript runtime error:
'sys' undefined

Rathinamoorthy said...

Much useful for the Freshers. Thanks a lot bro :)

Unknown said...

not working properly. no effect on button..

Unknown said...

only work in Internet Explorer !

vamsi said...
This comment has been removed by the author.
Unknown said...

not working in all browser ...

Anonymous said...


rajesh said...

this code is not working in chrome.

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.