asp.net上的javascript [英] javascript on asp.net

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

问题描述


我试图从
学习客户端脚本 http://msdn.microsoft.com/en-us/library/aa479302.aspx [ ^ ]

我不明白的是为什么我们要在类文件而不是.js文件上编写这些Java脚本函数.

我认为将.js文件添加到页面的src属性中或将其直接合并到您的项目中很容易,以便我们可以从后面的代码中访问函数.

如何在现实生活中的项目中添加JavaScript(普通的Web应用程序和AJAX中都启用了JavaScript)?

请告知..网络上有太多信息,对于初学者来说不容易在哪里开始练习.

Hi,
I was trying to learn client side scripting from
http://msdn.microsoft.com/en-us/library/aa479302.aspx[^]

what i don''t understand is why we are writing these java script functions on a class file rather than a .js file.

i was thinking its easy to add the .js file into src attribute of your page or directly incorporate into your project so that we can access the functions from the code behind.

How does the JavaScript gets added in real life project(both in normal web-application and AJAX enable ones)?

Please advise ..there is too much information in web for a beginner to get confused where to start practicing.

推荐答案

您当然可以在* .JS中静态编写Javascript.文件或将其嵌入HTML文件中.

Javascript是由APS.NET即时生成的HTML页面的一部分.通过插入后面的代码生成的值,可以对HTML输出的一部分进行参数化.可以用完全相同的方式来参数化Javascript代码的一部分:这是将代码结果插入Javascript代码后面的方法.如果不需要它,请写一个静态* .JS文件,为什么不呢?

-SA
You can certainly write Javascript statically in a *.JS file or write it embedded in HTML file.

Javascript is a part of HTML page generated by APS.NET on the fly exactly as anything else. You parametrize part of your HTML output by inserting the values generated by the code behind. Exactly in the same way you can parametrize the part of your Javascript code: this is the way to insert the result of code behind in the Javascript code. If you don''t need it, write a static *.JS file, why not?

—SA


阅读在ASP.NET .这将为您提供一些明确的指示,说明如何将JavaScript包含在ASP.NET应用程序中.基本上,通常不应在后面的代码中将JavaScript作为字符串包含在内.相反,您可以将.JS文件嵌入DLL,然后在页面中插入脚本引用(src ="...."),以便从DLL加载JavaScript.
Read Managing Your JavaScript Library in ASP.NET. That will give you some solid pointers on how you should be including JavaScript in your ASP.NET applications. Basically, you should normally not include JavaScript as strings in your code behind. Instead, you can embed a .JS file into a DLL and insert a script reference (src="....") into your page that loads that JavaScript from the DLL.


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

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