Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-26-2012, 09:59 PM   PM User | #1
SteveH
Regular Coder

 
Join Date: Nov 2005
Posts: 621
Thanks: 95
Thanked 1 Time in 1 Post
SteveH is an unknown quantity at this point
Option explicit error

Hello

If I do not insert a doctype (strict or loose are the types I have tried), my Web form page seems to work fine. But when I do, I get the following error:

Quote:
Microsoft VBScript compilation error '800a0400'

Expected statement

/contact_us.asp, line 9

option explicit
I would be happy to leave out the doctype, but I am trying to use the CSS 'focus' snippet

Code:
input:focus
{
background-color:yellow;
and for it to work,
Quote:
:focus to work in IE8, a DOCTYPE must be declared
according to the W3 Schools site:

http://www.w3schools.com/cssref/sel_focus.asp

How would I get round that problem, please?
SteveH is offline   Reply With Quote
Old 04-26-2012, 11:52 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,579
Thanks: 62
Thanked 4,064 Times in 4,033 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
ASP requires the OPTION EXPLICIT to be first on the page, excepting for <%@ xxx %> declarations.

So you really do need to put it before the DOCTYPE.

And it really is perfectly okay to do so.

Remember *NO* code in <%...%> tags is seen directly by the browser. Only if you Response.Write something from within <%...%> is it sent to the browser.

So if you write
Code:
<%@ Language="VBScript" %>
<% OPTION EXPLICIT %>
<!DOCTYPE html ... >
or even if you prefer for some reason to do
Code:
<%@ Language="VBScript" %>
<% OPTION EXPLICIT %>
<% Response.Write "<!DOCTYPE html ... >" %>
the browser will never see anything prior to the <!DOCTYPE...>.

And it is only what the browser sees that matters for any HTML tags, including <!DOCTYPE ...>
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Users who have thanked Old Pedant for this post:
SteveH (04-27-2012)
Old 04-27-2012, 12:33 AM   PM User | #3
SteveH
Regular Coder

 
Join Date: Nov 2005
Posts: 621
Thanks: 95
Thanked 1 Time in 1 Post
SteveH is an unknown quantity at this point
Hello Old Pedant

Quote:
ASP requires the OPTION EXPLICIT to be first on the page, excepting for <%@ xxx %> declarations.

So you really do need to put it before the DOCTYPE.
I think that needs emphasising sometimes - I have seen a few Web sites that state the DOCTYPE goes first.

My page is fine after your suggestion.

Many thanks.

Steve
SteveH is offline   Reply With Quote
Old 04-27-2012, 01:47 AM   PM User | #4
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,579
Thanks: 62
Thanked 4,064 Times in 4,033 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Quote:
Originally Posted by SteveH View Post
I have seen a few Web sites that state the DOCTYPE goes first.
If you don't use <%@ page %> directives and you don't use <% option explicit %>, which many many many sites do not, then yes, it goes first.

But, again, all that really matters is that it goes first in what the browser sees, not necessarily what the ASP (or PHP or JSP or ASP.NET) processor sees.
__________________
An optimist sees the glass as half full.
A pessimist sees the glass as half empty.
A realist drinks it no matter how much there is.
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:33 PM.


Advertisement
Log in to turn off these ads.