Reputation: 321
I have an asp button that is used to upload images (using uploadify) and it has also code behind . The problem is I want to run the client side script before postback. but the postback occurs while uploading images .
<ASP:BUTTON ID="Button1" runat="server" onclick="Button1_Click" onclientclick="Save();"/>
How can I force it to finish the client script first ?
Upvotes: 4
Views: 9670
Reputation: 460158
I thought that the Postback would happen after the onClientClick
has finished.
OK, then you could use a input type="button"
and trigger the Postback manually(__doPostBack('Button1,'');
).
But I'm pretty sure that the postback happens only after the onClientClick
has finished, because you can prevent a PostBack by returning false
from the onClientClick
. You should debug your javascript, because this behaviour is exceptional.
Upvotes: 4
Reputation: 1217
I came across similar case; for anyone who would face a simlar issue; my resolution was as
<ASP:BUTTON ID="Button1" runat="server" onclick="Button1_Click" onclientclick="return Save();"/>
Note that the onclientclick has the "return" keyword; this way when onclientclick is true onclick would fire; otherwise it would not.
Upvotes: 2