你在ASP.NET中需要JavaScript吗? [英] Do you need JavaScript in ASP.NET?

查看:46
本文介绍了你在ASP.NET中需要JavaScript吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我购买了一本名为Pro ASP.NET 2.0的书。为了加快网络上的速度

的东西,因为我通常都会使用Windows Form Applications ..但是在

的第一章我本周读到的它让我想起了一些事情我

过去听说过我认为有人可以澄清。


第6页它说明了

ASP.NET web页面(和Web服务)在CLR

(公共语言运行库)中执行,因此可以使用任何语言创建它们,即
具有符合CLR的编译器。您不再仅限于使用

VBScript或JavaScript,而是可以使用现代面向对象的

语言,如Visual Basic和C#。同样重要的是要注意

ASP.NET页面不会被解释,而是编译成

程序集。


我的一位朋友说:你仍然使用JavaScript来获取客户端数据

验证以及你想要的任何其他功能在客户端。你

仍然可以在HTML asp端嵌入代码,它只是没有效率或

非常反对这样做。


我只是想知道这是不是真的。


谢谢

解决方案

< blockquote>< th *********** @ yahoo.comwrote in message

news:11 ***************** *****@e3g2000cwe.googlegro ups.com ...


我的一位朋友说你仍然使用JavaScript作为客户端数据

验证以及您在客户端需要的任何其他功能。



这是对的。了解ASP.NET为

浏览器创建解析,解释和呈现的标记是至关重要的。浏览器本身确实有了b $ b,不需要知道哪个应用程序正在为它们提供这个标记...

当然,ASP.NET可以做的远不止那个服务器 - 方面,因为它有完全访问.NET Framework的权限,这就是它与

数据库,Active Directory,服务器的文件系统,电子邮件的接口。


但是,基本上,它与浏览器没有比通过

标准HTTP请求和响应更多的交互。比方说,如果你想用一个会说Hello world的按钮发送一个页面

。当用户点击它时,ASP.NET

可以为你做到这一点。但是,一旦该标记已经流式传输到

浏览器,ASP.NET就不知道接下来会发生什么,除非它/ b $ b从浏览器接收到另一个HTTP请求。如果用户点击

按钮,浏览器将显示一条提示Hello world的警告。因为

ASP.NET已经发送了实现这一点所必需的HTML和JavaScript。

但是ASP.NET本身并不知道这个事件有什么用

发生了,因为它发生在客户端。


您仍然可以在HTML asp端嵌入代码,它只是效率不高或

非常反对这样做。



我认为你朋友的意思是你的ASPX页面可以包含我们

呼叫在线的内容。服务器端代码,就像经典的ASP页面一样。这确实不会使事情效率低下或者没有针对性,因为服务器端代码即使它嵌入在ASPX页面中也是如此。



由服务器编译,实际上并没有流式传输到客户端。


我的一位朋友说你仍然使用JavaScript作为客户端数据


验证以及您在客户端需要的任何其他功能。你仍然可以在HTML asp端嵌入代码,它只是效率不高或者b / b
非常反对这样做。



是的,您可以嵌入Javascript / VBscript进行客户端编程。

请记住,所有ASP.NET都是生成。一些HTML和

它发送回浏览器的Javascript。您可以根据需要使用通常的< Scripttags嵌入您自己的

Javascript。或者你可能想要

从后面的代码中动态编写你的javascript,即:

Response.Write("< Script ...");


您还可以按照通常的

方式添加自己的javascript库。

是的,您可以将代码包括在内HTML而不是

代码隐藏文件。我曾经听说这实际上是MS如何实现其页面的
,而不是使用DLL背后的代码。我不确定它是否是真实的,但是假设它是安全性的,因为如果你手上有DLL,你可以反编译整个网站。

就个人而言,我仍然希望以这种方式输入一些内联代码,而且我不是。
确定为什么你的朋友认为它不是面向对象的。


SN


谢谢大家,我很感激他的回复很好..

John

Steven Nagy写道:


我的一位朋友说你仍然使用JavaScript作为客户端数据

验证以及您在客户端需要的任何其他功能。你仍然可以在HTML asp端嵌入代码,它只是效率不高或者b / b
非常反对这样做。



是的,您可以嵌入Javascript / VBscript进行客户端编程。

请记住,所有ASP.NET都是生成。一些HTML和

它发送回浏览器的Javascript。您可以根据需要使用通常的< Scripttags嵌入您自己的

Javascript。或者你可能想要

从后面的代码中动态编写你的javascript,即:

Response.Write("< Script ...");


您还可以按照通常的

方式添加自己的javascript库。

是的,您可以将代码包括在内HTML而不是

代码隐藏文件。我曾经听说这实际上是MS如何实现其页面的
,而不是使用DLL背后的代码。我不确定它是否是真实的,但是假设它是安全性的,因为如果你手上有DLL,你可以反编译整个网站。

就个人而言,我仍然希望以这种方式输入一些内联代码,而且我不是。
确定为什么你的朋友认为它不是面向对象的。


SN


I purchased a book titled "Pro ASP.NET 2.0" to get up to speed on web
stuff because I ususally do Windows Form Applications.. But in the
first chapters I was reading this week it brought to mind some things I
heard in the past that I thought someone could clarify.

On Page 6 it states
"ASP.NET web pages (and web services) are executed within the CLR
(common language runtime), so they can be authored in any language that
has a CLR-compliant compiler. No longer are you limited to using
VBScript or JavaScript, instead you can use modern object-oriented
languages such as Visual Basic and C#. It''s also important to note that
ASP.NET pages are not interpreted but are instead compiled into
assemblies."

A friend of mine said "You still use JavaScript for client side data
validation and whatever other features you want on the client side. You
can still embed code on the HTML asp side, it''s just not efficient or
very objected oriented to do so.

I just wanted to know if this is true.

Thanks

解决方案

<th***********@yahoo.comwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...

A friend of mine said "You still use JavaScript for client side data
validation and whatever other features you want on the client side.

That''s right. It''s fundamental to understand that ASP.NET creates markup for
browsers to parse, interpret and render. The browsers themselves really have
no need to know what application is serving this markup to them... Of
course, ASP.NET can do much more than that server-side, because there it has
full access to the .NET Framework, which is how it interfaces with
databases, Active Directory, the server''s file system, email etc.

But, essentially, it has no more interaction with your browser than through
standard HTTP requests and responses. If, say, you want to send down a page
with a button which will say "Hello world" when the user clicks it, ASP.NET
can do that for you. But once that markup has been streamed down to the
browser, ASP.NET has no knowledge of what happens next until / unless it
receives another HTTP request from the browser. If the user clicks the
button, the browser will display an alert saying "Hello world" because
ASP.NET has sent down the HTML and JavaScript necessary to make this happen.
But ASP.NET itself has no knowledge whatsoever of this event having
happened, because it has happened client-side.

You can still embed code on the HTML asp side, it''s just not efficient or
very objected oriented to do so.

I think what your friend means is that your ASPX pages can contain what we
call "in-line" server-side code, just as classic ASP pages did. This does
not necessarily make things inefficient or not objected orientated, because
the server-side code even though it''s embedded in the ASPX page gets
compiled by the server and is not actually streamed down to the client.


A friend of mine said "You still use JavaScript for client side data

validation and whatever other features you want on the client side. You
can still embed code on the HTML asp side, it''s just not efficient or
very objected oriented to do so.

Yes you can embed Javascript/VBscript for client side programming.
Just remember that all ASP.NET does is "generate" some HTML and
Javascript that it sends back to the browser. You can embed your own
Javascript with the usual <Scripttags as necessary. Or you might want
to write your javascript dynamically from the code behind, ie:
Response.Write("<Script...");

And you can also include your own javascript libraries as per the usual
ways.
And yes you can include your code inline with the HTML instead of in
code behind files. I once heard that this is actually how MS implements
its pages, instead of using code behind DLL. I am not sure if it is
true or not, but the supposed reason for it was security, in that if
you got your hands on the DLL, you can decompile the entire site.
Personally I still like to enter some code inline this way, and I''m not
sure why your friend thinks its not Object Oriented to do so.

SN


Thanks guys, I appreciate he good responses..

John
Steven Nagy wrote:

A friend of mine said "You still use JavaScript for client side data
validation and whatever other features you want on the client side. You
can still embed code on the HTML asp side, it''s just not efficient or
very objected oriented to do so.


Yes you can embed Javascript/VBscript for client side programming.
Just remember that all ASP.NET does is "generate" some HTML and
Javascript that it sends back to the browser. You can embed your own
Javascript with the usual <Scripttags as necessary. Or you might want
to write your javascript dynamically from the code behind, ie:
Response.Write("<Script...");

And you can also include your own javascript libraries as per the usual
ways.
And yes you can include your code inline with the HTML instead of in
code behind files. I once heard that this is actually how MS implements
its pages, instead of using code behind DLL. I am not sure if it is
true or not, but the supposed reason for it was security, in that if
you got your hands on the DLL, you can decompile the entire site.
Personally I still like to enter some code inline this way, and I''m not
sure why your friend thinks its not Object Oriented to do so.

SN


这篇关于你在ASP.NET中需要JavaScript吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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