locked
disable button while processing RRS feed

  • Question

  • User-125499312 posted

    i have a button that triggers a process for about 30 seconds

    i would like to disable button at the beginning and enable it when done.

    how do i do this?

    thx for ur help

    Sunday, August 30, 2020 5:07 PM

All replies

  • User1535942433 posted

    Hi yzidell,

    Accroding to your description,I suggest you could use jquery to disable the button if you could use any way to achieve the requirment you want.You could use settimeout to wait 30 seconds.

    More details,you could refer to below codes:

     <asp:Button ID="Button1" runat="server" Text="Button" />
    
      <script src="Scripts/jquery-3.4.1.min.js"></script>
        <script type="text/javascript">
            $(document).ready(function () {
                $("#Button1").click(function () {
                    var $this = $(this);
                    $this.val('Please wait..');
                    $this.attr('disabled', true);
                    setTimeout(function () {
                        $this.attr('disabled', false);
                        $this.val('Button');
                    }, 2000);
                });
            });
        </script>

    Result:

    Best regards,

    Yijing Sun

    Monday, August 31, 2020 2:06 AM
  • User-125499312 posted

    thank you for responding

    what happens if the backend process takes longer than 30 seconds?

    i do not want the user to click the button while the server is still processing.

    Monday, August 31, 2020 1:10 PM
  • User1535942433 posted

    Hi yzidell,

    As far as I think,you need to have a precise time or you could monitor the event.

    More details,you could refer to below articles:

    https://stackoverflow.com/questions/61194276/progress-bar-not-updating-even-with-settimeout

    https://ux.stackexchange.com/questions/10336/disabled-buttons-while-long-running-task

    Best regards,

    Yijing Sun

    Tuesday, September 1, 2020 8:12 AM