如何asp.net按钮的回发之前运行javascript函数 [英] How to run a javascript function before postback of asp.net button

查看:107
本文介绍了如何asp.net按钮的回发之前运行javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个asp.net按钮,这是RUNAT服务器,有一个函数处理按钮的回发的onclick。

I have an asp.net button which is runat server, there is a function handle that postback of button onclick.

我如何才去服务器程序显示在页面中一个载入中...字?

How can I display a "loading ..." word in the page before going to the server procedure?

推荐答案

挂钩的OnClientClick到返回true或false一些JavaScript功能。如果返回true,否则将被取消时,会出现回发。

Hook up OnClientClick to some javascript function that returns true or false. The postback occurs if it returns true else it is canceled.

  <asp:Button id="MyButton" runat="Server" Text="Close" 
                       OnClientClick="return  PromptClose();"/>


  <script type="text/javascript">
   function PromptClose(){
       return prompt("Do you really want to close this window?");
   }
  </script>

这篇关于如何asp.net按钮的回发之前运行javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆