Home > ASP.Net > Prevent Double Click On Button Twice

Prevent Double Click On Button Twice


try this example:

//-- CSS style

<style type="text/css">
      visibility: hidden;
      display: none;
      position: absolute;
      top: -100px;
      left: -100px;

      position: absolute;
      top: 0px;
      left: 0px;
      visibility: visible;
      display: block;
      width: 100%;
      height: 100%;
      background-color: #666;
      z-index: 999;
      padding-top: 20%;

      text-align: center;
      width: 66%;
      background-color: #171;
      color: White;
      font-size: large;
      border: dashed 2px #111;
      padding: 9px;

//--- Javascript function

<script type="text/javascript">
function button1OnClick(msg)
 var isValid = Page_ClientValidate();
 if ( isValid == true )
      var outerPane = document.getElementById('FreezePane');
      var innerPane = document.getElementById('InnerFreezePane');
      if (outerPane) outerPane.className = 'FreezePaneOn';
      if (innerPane) innerPane.innerHTML = msg;
 return false;

//-- Controls

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"
            ErrorMessage="RequiredFieldValidator" SetFocusOnError="True">*</asp:RequiredFieldValidator><br />
        <br />
        <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="button1OnClick('Please Wait ..');" OnClick="Button1_Click"  />
    <div align="center" id="FreezePane" class="FreezePaneOff">
     <div id="InnerFreezePane" class="InnerFreezePane"> </div>

in code behind :-

protected void Button1_Click(object sender, EventArgs e)

Hope this helps

Good Luck

Categories: ASP.Net
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: