0

I know many people will jump on and try to mark this as possible duplicate of Call an asynchronous javascript function synchronously, but my requirement is with asp.net web forms. In the button click event which causing as postback, first I wanted to make a call to async javascript function synchronously and get the response from it and then submit the page or continue with post back.

The js library I am using is third party one which I don't have any control over and won't support async:false

Is it possible and how ??

A simple google search gives me options like, jQuery Promises, Deferred etc and below links. I just don't know how do I use those with asp.net

https://www.quora.com/How-do-you-make-an-async-function-synchronous and https://github.com/abbr/deasync

Community
  • 1
  • 1

1 Answers1

0

You can use the onclientclick attribute of asp.net button.

Below is an example on how to use it :

 <asp:button id="Button1"
   usesubmitbehavior="true"
   text="Open Web site"
   onclientclick="CallAjax()"
   runat="server" onclick="Button1_Click" />

I hope this helps.

Rahul Jain
  • 3,130
  • 1
  • 14
  • 16