Closed Thread
Results 1 to 4 of 4

Thread: Disable a button

  1. #1
    reachpradeep's Avatar
    reachpradeep is offline Learning Programmer
    Join Date
    Mar 2007
    Location
    India
    Posts
    41
    Rep Power
    0

    Disable a button

    I have a Save button on a web page.
    I want to disable the button when clicked, so that the user does not click it more than once, as the serevr side code is being processed.
    i disabled the button by calling a javascript function -
    btnSave.Attributes.Add("onClick","return buttonDisabled();") ;

    In the Javascript file i have -
    function disableButton()
    {
    var btnSave = document.getElementById('btnSave') ;
    btnSave.disabled = true ;
    return true ;
    }

    since the button gets disabled my server side code(in C#) does not get executed.
    thanks a lot for any kind of help

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Join Date
    Mar 2007
    Posts
    7
    Rep Power
    0
    Your button:
    <input type = submit id = "btnSave" onclick = "disableButton()">

    The Javascript function:
    function disableButton() {
    var btnSave = document.getElementById('btnSave') ;
    btnSave.disabled = true ;
    yourformname.submit();
    }


    I hope this solves your problem.

  4. #3
    majnad1 is offline Newbie
    Join Date
    Apr 2010
    Posts
    1
    Rep Power
    0

    Re: Disable a button

    Here's an entertaining article with a step-by-step explanation of the one-click only functionality especially for ASP.NET:

    http://blog.webonweboff.com/2010/04/...once-only.html

    Click button once only

    Hope this helps

  5. #4
    gokuajmes's Avatar
    gokuajmes is offline Programming God
    Join Date
    Jan 2010
    Location
    India
    Posts
    516
    Blog Entries
    5
    Rep Power
    12

    Re: Disable a button

    because it is a ASP.NET application.do write the client script under OnClientClick. then double click the button to write asp.net code for it it would look something of this sort

    Code:
    <asp:Button id="btn1" text="Submit" onClientClick="this.visible=false" onClick="btn1_Click()" runat="server"/>

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 04-19-2011, 08:47 AM
  2. Disable Button on Timer?
    By oldezwe in forum Java Help
    Replies: 5
    Last Post: 02-24-2011, 01:45 PM
  3. Intermediate Disable an applications close button (The X)
    By PsychoCoder in forum CSharp Tutorials
    Replies: 2
    Last Post: 10-21-2010, 11:17 AM
  4. disable
    By YAR in forum C# Programming
    Replies: 3
    Last Post: 12-29-2008, 10:45 AM
  5. C# to disable a device
    By NeedHelp in forum C# Programming
    Replies: 4
    Last Post: 07-24-2006, 12:34 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts