Disable a button control during postback.

Filed under: Programming — ej2 at 8:13 am on Wednesday, August 29, 2007

Here is very simple (non-AJAX) way to disable a button control during postback:

<asp:Button runat="server" ID="BtnSubmit"
OnClientClick="this.disabled = true; this.value = 'Submitting...';"
UseSubmitBehavior="false"
OnClick="BtnSubmit_Click"
Text="Submit Me!" />

Found here.

2 Comments »

919

Comment by apex

July 14, 2008 @ 12:49 pm

this doesn’t work with firefox so it’s uselless, but thanks for efort

920

Comment by ej2

July 14, 2008 @ 1:35 pm

Works great for me. I tested with Firefox 3.0 using the following code for the button click:


protected void BtnSubmit_Click(object sender, EventArgs e)
{
Thread.Sleep(4000);
label.Text = DateTime.Now.ToString();
}

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Comment spam protected by SpamBam