What is 'script' in a ASPNET file

  • Thread starter Thread starter Marc
  • Start date Start date
M

Marc

Comming from JSP-HTML when I hear 'script' I think of JavaScript or perhaps
VBScript. But I think in ASP.NET they mean something else? I am bit confused
now.

Reading a book I see the following:

A simple Web page may look like the following.
<!-page directives-->
<%@ Page Language="VB" %>

<!--script-->
<script runat="server">
Private Sub SayHi(ByVal sender As Object, ByVal args As EventArgs)
Response.Write("Hello " + txtName.Value) End Sub
</script>

<!--layout-->
<html>
<head> <title>Say Hi Page</title> </head>

<body>
<form id="form1" runat="server"> <input runat="server" id="txtName"
type="text" /> <input runat="server" id="btnSayHi" type="button"
value="Say Hi" onserverclick="SayHi" />
</form>
</body>
</html>

Hence script refers to a piece of Visual Basic code here. Appearantly.

My question hence are:

1. Can you use javascript in ASP.NET pages?
2. Can you use VBScript in ASP.NET pages?
3 Does 'script' refer to the .NET C# or Visual Basic code, or to what I
should call real /scripting/ lanuguage code, like code in JavaScript of
VBScript?
4 Can anyone tell me if and what the difference would be with Java in a JSP
page and f.e. C# in an ASP.NET page

Marc Wentink

N.B. The question refers to the book I am reading Self Pace Training Kit for
the 70-528 Exam written by Glen Johnsson
 
There are two ways of creating code in ASP.Net. One is inline scripting,
which you are seeing. There, technically, it's not scripting as you
remember, but you would use the language of your choice - either VB.Net or
C# - so when you see VB - it's VB.Net coding - not VBScript, as it was in
Classic ASP days.

The other way that quite a few people use is 'code-behind', which is a
separate page for the coding, and it's tied to the ASPx page in the Page
directive

David Wier
http://aspnet101.com
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
bloated markup
 
Mark Rae said:

But then client side, I presume?
<script runat="server"/> tag.

Which means server side code, and hence code in a .NET assembly, not code in
a scripting language like JScript VBScript, et cetera, right? Actually I was
confused by calling code in server side modules script. I would, perhaps
only call client side interpreter (javascript) code script.

Thank you, thank you, & thanks
 
it holdover from asp (which was script based), which used the tag to define
server script blocks.

asp.net differs from asp and jsp in the rules for <% %> and <script
runat="server">. the asp.net page is compiled into a class file.

all methods and class variables must be defined in <script runat="server">
as this code is paced between the class def, and the first method definition.

you can think of all the html and <% %> code as all contained in one method
call. all html is converted to a new literal.html = html, and <%%> code is
generated inline. this means code in <% %> must be legal inside a method def.

<%= expression %> is converted new literal.html = expression


-- bruce (sqlwork.com)
 
INLINE

Marc said:
Comming from JSP-HTML when I hear 'script' I think of JavaScript or
perhaps VBScript. But I think in ASP.NET they mean something else? I am
bit confused now.

Reading a book I see the following:

A simple Web page may look like the following.
<!-page directives-->
<%@ Page Language="VB" %>

<!--script-->
<script runat="server">
Private Sub SayHi(ByVal sender As Object, ByVal args As EventArgs)
Response.Write("Hello " + txtName.Value) End Sub
</script>

<!--layout-->
<html>
<head> <title>Say Hi Page</title> </head>

<body>
<form id="form1" runat="server"> <input runat="server" id="txtName"
type="text" /> <input runat="server" id="btnSayHi" type="button"
value="Say Hi" onserverclick="SayHi" />
</form>
</body>
</html>

Hence script refers to a piece of Visual Basic code here. Appearantly.

My question hence are:

1. Can you use javascript in ASP.NET pages?

Yes, for client side operations you can use JavaScript. In fact, all of the
AJAX bits output JavaScript to run on the client side.
2. Can you use VBScript in ASP.NET pages?

I would not use VBScript, personally, as it limits you to IE.
3 Does 'script' refer to the .NET C# or Visual Basic code, or to what I
should call real /scripting/ lanuguage code, like code in JavaScript of
VBScript?

I am sure some call the code "script", but I would not. The reason is
"script" generally means interpreted, not compiled. By interpreted, I mean
that the code in script runs in the browser, at run time. There is no
compilation step.
4 Can anyone tell me if and what the difference would be with Java in a
JSP page and f.e. C# in an ASP.NET page

Different object models. :-)

Essentially, if you are using JSP, you have Java for your server code and
JavaScript for your client code.

In ASP.NET, you have C#/VB for your server code and JavaScript for your
client code.

You can use VBScript in either, if you are so inclined.

Underneath the hood, the thinking process behind Java (JSP) and C#/VB
(ASP.NET) are quite different. And, each has its strengths and weaknesses.

Good enough?

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

********************************************
| Think outside the box! |
********************************************
 
the server code can be written in any .net language.

there are three out of the box (no additional installs required):
javascript.net (clr based)
c# (clr based)
vb.net (clr based)

there are couple common dynamic languages available

jscript.net (dlr based javascript - comes with silverlight)
ironpyhon (dlr based)
ironRuby (dlr based)
f# (dlr based)

you might want to look at the new mvc framework, which should replace
webforms for all enterprise programers.

-- bruce (sqlwork.com)
 
re:
!> javascript.net (clr based)

Is that still available ?
I don't see any option in VS 2008 to create a JScript.Net-based website.

I think that JScript.Net has been removed from our arsenal.

re:
!> there are couple common dynamic languages available

With 3rd party tools, there's quite a few more.

I've been dabbling with PHP.NET, using Phalanger.

http://www.codeplex.com/Wiki/View.aspx?ProjectName=Phalanger

If a PHP programmer wants to dabble with .NET, there's almost no learning curve.
Phalanger even integrates with Visual Studio.




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
 
re:
!> I don't see any option in VS 2008 to create a JScript.Net-based website.
!> I think that JScript.Net has been removed from our arsenal.

I thought that I had seen an annoucement of that, so I looked it up...and here it is :

http://msdn.microsoft.com/en-us/vjsharp/default.aspx

<quote>
Since customers have told us that the existing J# feature set largely meets their needs
and usage of J# is declining, Microsoft is retiring the Visual J# product and Java Language
Conversion Assistant tool to better allocate resources for other customer requirements.

The J# language and JLCA tool will not be available in future versions of Visual Studio.

To preserve existing customer investments in J#, Microsoft will continue to support
the J# and JLCA technology that shipped with Visual Studio 2005 through to 2015
as per our product life-cycle strategy.
</quote>




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
 
Juan T. Llibre formulated on vrijdag :
re:
!> I don't see any option in VS 2008 to create a JScript.Net-based website.
!> I think that JScript.Net has been removed from our arsenal.

I thought that I had seen an annoucement of that, so I looked it up...and
here it is :

http://msdn.microsoft.com/en-us/vjsharp/default.aspx

<quote>
Since customers have told us that the existing J# feature set largely meets
their needs
and usage of J# is declining, Microsoft is retiring the Visual J# product and
Java Language
Conversion Assistant tool to better allocate resources for other customer
requirements.

The J# language and JLCA tool will not be available in future versions of
Visual Studio.

To preserve existing customer investments in J#, Microsoft will continue to
support
the J# and JLCA technology that shipped with Visual Studio 2005 through to
2015
as per our product life-cycle strategy.
</quote>

Isn't J# a language that Microsoft isn't allowed to call "Java", but
looks a lot like that?
While JScript.Net is a .Net enhancement of j(ava)SCRIPT (to be run on
the server side in a ASP.Net application).
Maybe it needs to be installed specifically (as opposed to C# and
VB.Net that get installed automatically)?

Hans Kesting
 
re:
!> Isn't J# a language that Microsoft isn't allowed to call "Java", but looks a lot like that?
!> While JScript.Net is a .Net enhancement of j(ava)SCRIPT
!> (to be run on the server side in a ASP.Net application).

J#, Visual J# and vjsharp are all the same product, which is being retired.
You can *use* J# forever, but it won't be updated any more and support will end in 2015.

JScript and JScript.Net are Microsoft versions of JavaScript.
The latest version is JScript 8.0.

You can use JScript, if the redistributable is installed,
in an .aspx page by declaring it as the page language :

<%@ language="JScript" %>

You can also use it in Webservices, if the redistributable is installed :

<%@ WebService Language="JScript" class="YourClass"%>

re:
!> Maybe it needs to be installed specifically
!> (as opposed to C# and VB.Net that get installed automatically)?

You *can* install the Visual J# redistributable and it will work in VS 2008.

It's here :
http://msdn.microsoft.com/en-us/vjsharp/bb188598.aspx

Support for Visual J# is not natively offered in VS 2008, though.
Visual J# was removed from Visual Studio 2008.

You don't have to install it for VS 2005, because support for it is built-in,
although only for Windows and Console programs, not for Web applications.

To add to all this jumble, there's also "Managed JScript",
which is different from JScript *and* from JScript.Net.

It's used by Silverlight.

Read about the differences between the several flavors of JScript here:
http://blogs.msdn.com/gauravseth/ar...-jscript-jscript-net-and-managed-jscript.aspx




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
 
Back
Top