开发者

Forcing button control to run its client side before postback

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 ?


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜