script placement

  • Thread starter Thread starter Thomas Scheiderich
  • Start date Start date
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.
 
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.
 
Back
Top