script placement

T

Thomas Scheiderich

In one of my ASP.NET books, it states that one of the differences
between ASP.NET and classic ASP, is that in classic you can have script
code anywhere in your html page. But that in ASP.NET, it must precede
the Body of the page.

I have one here called rolldice.aspx which works fine with the script
code before or after the <body> tag.

******************************************************
<HTML>
<HEAD>
<TITLE>Roll Dice</TITLE>
</HEAD>
<BODY>

<script runat="server">

function RollDie As Integer
Dim Roll As Integer
Randomize
Roll = Int(rnd * 6) + 1
Return(roll)
end function

</script>

<p>I'll roll two dice; let's see what
we get!</p>

<%
Dim FirstRoll, SecondRoll As Integer
FirstRoll = RollDie
SecondRoll = RollDie

%>

<p>First roll: <%=firstroll%><br>
<p>Second roll: <%=secondroll%><br>
</body>
</html>
************************************************************

Why is this? Did I miss read the statement?

Thanks,

Tom.
 
T

Thomas Scheiderich

Rick said:
Thomas,

That book is incorrect. Script can really go anywhere on the page.


So there really is no difference between script, when using VB (not
talking about the difference between VBScript and VB.NET).

I was curious as to why I don't need to put put the "Language" tag
inside the script as I used to, to tell what type of script it is?

******************************************************
<HTML>
<HEAD>
<TITLE>Roll Dice</TITLE>
</HEAD>
<BODY>

<script runat="server">

************************************************************

Thanks,

Tom.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top