Disable dynamic pressing of the asp.net button during postback and enable it later

I dynamically create a button in my code and attach a click event to it. However, I have to keep people from clicking on it while the process is running. Therefore, when it is clicked once, it must be turned off, and when the process is completed, it must be turned on. How can i do this?

Thanks.

+5
source share
3 answers

onclick = "this.enabled = false" add this from your code to your control

btnAdd.Attributes.Add ("onclick", "this.enabled = false;");

http://encosia.com/2007/04/17/disable-a-button-control-during-postback/

+4

ajax - 1. 2.

postbacks, - , javascript [ jquery ]. , , .

    <asp:Button ID="btn" runat="server" OnClientClick="disable(this)"
Text="Click me!" OnClick="btn_Click" />

 <script type="text/javascript">
        function disable(control)
        {
            control.disabled="disabled";
            //added alert to give the snapshot of what happens
            //when the button is clicked
            alert(100);
        }
 </script>

, .

+2

UpdatePanel . . , x , . Windows.

0
source

All Articles