Eme*_*ech 11 javascript asp.net postback
我想在页面回帖之前用javascript做点什么.
如何在任何asp.net回发之前运行javascript函数?
$('form').submit(function () {
alert('hello');
});
Run Code Online (Sandbox Code Playgroud)
它不起作用...... :(
Eme*_*ech 17
我找到了方法,在asp.net论坛中,它是代码隐藏中的一些代码.
只需将其添加到Page_Load事件处理程序,将javaScript字符串更改为您想要发生的事件.
string scriptKey = "OnSubmitScript";
string javaScript = "alert('RegisterOnSubmitStatement fired');";
this.ClientScript.RegisterOnSubmitStatement(this.GetType(), scriptKey, javaScript);
Run Code Online (Sandbox Code Playgroud)
如果你想在 asp的回发之前做客户端的事情,尝试使用的OnClientClick属性asp:button,例如:
<asp:Button OnClick="submit" OnClientClick="myPrePostbackFunction()" Text="Submit" runat="server" ... />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9506 次 |
| 最近记录: |