Delete button while progress is displayed

I have a button in the form of an ASPp application for an ASP.NET application, and when I click it it turns off and sends information to a third-party web service.

I have UpdateProgress associated with a button.

how to disable / hide the button until progress is visible (i.e. the server has not completed the operation)

I look at this to stop the button from being clicked again when sending information (since this leads to sending duplicate information)

+3
source share
3 answers

javascript- (Sys.WebForms.PageRequestManager.getInstance(). add_initializeRequest). , , , (., ).

ASP.NET

<div id="ButtonBar">
  <asp:Button id= ............
</div>

Javascript

<script language="javascript">
  // Get a reference to the PageRequestManager.
  var prm = Sys.WebForms.PageRequestManager.getInstance();

  // Using that prm reference, hook _initializeRequest
  // and _endRequest, to run our code at the begin and end
  // of any async postbacks that occur.
  prm.add_initializeRequest(InitializeRequest);
  prm.add_endRequest(EndRequest);

  // Executed anytime an async postback occurs.
  function InitializeRequest(sender, args) 
  {
    $get('ButtonBar').style.visibility = "hidden";
  }

  // Executed when the async postback completes.
  function EndRequest(sender, args) 
  {
    $get('ButtonBar').style.visibility = "visible";
  }
</script>

. ASP.NET AJAX Dave Ward.

+3

png - . -, .

AJAX .

, (- 1 ).

+1

I also wrote a blog post about this, which I hope is useful for you: http://www.fitnessconnections.com/blog/post/2008/01/Disabling-a-submit-button-UpdatePanel-Update-method. aspx

Greetings :)

0
source

Source: https://habr.com/ru/post/1697666/


All Articles