Wednesday, September 7, 2011

How to disable a button (e.g. Submit button) on client side

If you want to disable a button as soon as user click on it (so they don't click multiple times) , you have to do it on client side. Below is how you can do this.

  1. Add the button first

<asp:button causesvalidation="false" id="SubmitButton" onclick="SubmitButton_Click" onclientclick="DisableSubmitButton()" runat="server" text="Submit" usesubmitbehavior="false">

  1. Add this JavaScript function to the page and you set to go.

function DisableSubmitButton(url) {
var button = document.getElementById('&lt;%= SubmitButton.ClientID %&gt;');
button.disabled = true
button.value = 'Submitting...';
__doPostBack('SubmitRadButton', '')

How to post code snippet on blogger

I had hard time to put my code snippet on blogger and that is because I don't do that much of blogging but I am starting to enjoy it. Thanks to BlogPandit  to give the instructions for this. I am just repeating them.

When you want to add part of your code (specially code) you need to do couple of steps to get the code ready for blogger editor. Here they are:

  1. Get your code parsed using the following link Blogcrowds 
  2. Get the parsed code and put it inside of  blockquote tags 
  3. Your are good to go