做asp.net anypostback之前的JavaScript的东西 [英] Do something javascript before asp.net anypostback

查看:117
本文介绍了做asp.net anypostback之前的JavaScript的东西的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要做的Java脚本的东西页无二后回来。

i wanna do something in java script before page goes for post back.

如何运行任何asp.net回发前一个javascript函数?

how to run a javascript function before any asp.net postback?

$('form').submit(function () {
      alert('hello');
});

它不工作...:(

it doesnt work... :(

推荐答案

我找到方式,在 ASP。网论坛,这是在codebehind一个有些code。

I find the way, in the asp.net forums and it was a some code in codebehind.

只需添加到您的Page_Load事件处理程序,改变的JavaScript字符串到要发生什么。

Just add this to your Page_Load event handler, changing the javaScript string to what you want to happen.

string scriptKey = "OnSubmitScript";
string javaScript = "alert('RegisterOnSubmitStatement fired');";
this.ClientScript.RegisterOnSubmitStatement(this.GetType(), scriptKey, javaScript);

这篇关于做asp.net anypostback之前的JavaScript的东西的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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