我想在asp.net中执行一个javascript函数,以执行page_load事件 [英] I want to execute a javascript function befor execution of page_load event in asp.net

查看:146
本文介绍了我想在asp.net中执行一个javascript函数,以执行page_load事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在执行page_load()事件之前执行在客户端编写的java脚本函数

Plz有人帮我....谢谢

I want to execute a java script function written on client side before execution of page_load() event
Plz some one help me....thanks

推荐答案

参考:

1. 如何执行-jquery-script-before-page-load [ ^ ]

2. ASP.NET页面生命周期 [ ^ ]
Refer:
1. how-to-execute-jquery-script-before-page-load[^]
2. ASP.NET Page Life Cycle[^]


解决方案1有一个链接到您的答案,但我会在这里解释一下。



你不能这样做,等等。



什么时候你访问一个网页,首先要做的就是所有的C#运行和IIS / .Net生成html并将html和任何支持文件(css,images,javascript)发送到您的浏览器,然后您的浏览器会对其进行解析。此时你可以运行JavaScript。



我说的原因是因为你可以在页面回发之前以及在回发Page_Load再次运行期间运行JavaScript。有时在按钮上单击我们运行JavaScript以验证表单是否已填写然后我们让它回发在服务器端的Page_Load将运行的那一点。这是唯一的方法,但你问的方式确实没有任何意义。



客户端和服务器完全断开连接。
Solution 1 has a link to your answer but I'll explain it here.

You can't do this, sort of.

When you visit a web page the first thing to happen is all of the C# runs and IIS/.Net generate html and send the html and any supporting files (css, images, javascript) to your browser and then your browsers parses it. At that point you can run JavaScript.

The reason I say sort of is because you can have JavaScript run before the page postsback and during a postback Page_Load runs again. Sometimes on a button click we run JavaScript to validate the form is filled in and then we let it postback at which point on the server side the Page_Load will run. This is the only way to do that but the way you are asking really does not make any sense.

Client and Server are totally disconnected.


这篇关于我想在asp.net中执行一个javascript函数,以执行page_load事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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