代码隐藏文件中的JavaScript代码 [英] JavaScript code in codebehind file

查看:70
本文介绍了代码隐藏文件中的JavaScript代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



从codebehind调用javascript有什么用.
我们可以从客户端源调用javascript.

Hi ,

What is the use of calling javascript from codebehind.
We can call javascript from clientside source.

thanks.

推荐答案

问题也不正确,因为"codebehind" 从不调用JavaScript .

您如何看待这样的电话? 代码隐藏"是在服务器部分执行的,JavaScript在托管解释器的浏览器中执行.您需要了解Web应用程序的功能以及HTTP的工作方式.真正发生的是:ASP.NET代码可以响应HTTP请求.结果,它会生成一些HTTP响应,并将其发送回客户端.而已.现在-注意-HTTP响应可以是任何东西.特别是,它可以是(最通常是带有JavaScript的HTML文件). JavaScript代码仅是即时生成的,其文本是即时生成的,这可能会给您印象".实际上,它仅在客户端执行.

—SA
The question is also incorrect because "codebehind" never ever calls JavaScript.

How do you think it could do such call? "Codebehind" is something executed on server part, and JavaScript is executed in the browser hosting the interpreted. You need to learn what Web application does and how HTTP works. What really happens is: ASP.NET code works in response to HTTP request. As a result, it generates some HTTP response, which is sent back to the client. That''s it. Now — attention — HTTP response can be anything. In particular, it can be (and most typically is) some HTML file with JavaScript. JavaScript code is simply generated on the fly, and its text is composed on the fly, which might give you "impression" of the call. In fact, it is executed solely on the client side.

—SA


这篇关于代码隐藏文件中的JavaScript代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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