Setting Strict On

T

tshad

I am trying to set "Option Strict On" on my single .aspx page. I am not
using code-behind or VS. I am running this in DW on Asp.net 1.1

If I do the following:
*************************************************************************
<%@ Page Language="VB" trace=true debug=true ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<script Language="vb" runat=server>
Option Strict On
Sub Page_Load()

End Sub

</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>

</body>
</html>
**************************************

I get the error:
**********************************************
Compiler Error Message: BC30627: 'Option' statements must precede any
declarations or 'Imports' statements.

Source Error:

Line 2: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
Line 3: <script Language="vb" runat=server>
Line 4: Option Strict On <-- the error line
Line 5: Sub Page_Load()
Line 6:

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

There are no Imports statements.

I tried to put the Script at the top of the page - but got the same error:
*************************************************
<script language="vb" runat="server">
Option Script On
</script>
<%@ Page Language="VB" trace=true debug=true ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<script Language="vb" runat=server>
Sub Page_Load()

End Sub

</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>

</body>
</html>
**************************************************

How do I put my Option in my Script if I can't put it at the beginning of my
script section or beginning of the page?

Thanks,

Tom
 
M

Mattias Sjögren

How do I put my Option in my Script if I can't put it at the beginning of my
script section or beginning of the page?

In the @ Page directive, set Strict="true".


Mattias
 
P

Patrice

For completeness this is because ASP.NET creates code for your whole page
and the directive is not placed at the appropriate location in the generated
code...

tshad said:
Mattias Sjögren said:
In the @ Page directive, set Strict="true".

That was it.

And Explicit works the same way.

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

Top