|
For an ASP.NET web page, you must indicate that the script will be processed by the server. To support this, the <script> tag is equipped with the RUNAT attribute, to which you should assign server as a string. This would be done as follows: <%@ Page Language="VB" %> <html> <head> <script language="vbscript" type="text/vbscript" runat="server"> </script> <title>Exercise</title> </head> <body> </body> </html> Here is the same thing done for Visual Basic: <%@ Page Language="VB" %> <html> <head> <script language="vb" type="text/vb" runat="server"> </script> <title>Exercise</title> </head> <body> </body> </html> After creating a script tag, you can include the desired code in it. For example, you can declare a variable. You can then use that variable locally in the script section or use it in the <% ... %> section of the web page. Here is an example: <%@ Page Language="VB" %>
<html>
<head>
<script language= "vb" type="text/vb" runat="server">
Dim FullName As String
</script>
<title>Exercise</title>
</head>
<body>
<%
FullName = "Paul Bertrand Yamaguchi"
%>
<%
Response.Write("<br>Full Name: " & FullName)
%>
</body>
</html>
Remember that many other scripting languages are available. Because of their flexibility, for the rest of our lessons, we will mostly use VB and VBScript script languages.
The scope of a variable determines the areas of code where the variable is available.
A variable that is declared outside of a delimiting area is referred to as global. For example, you can declare a variable in the script section in the head section. To declare a global variable, use the same formula as we have done so far. |
|
|||||||
|
|