"'If' must end with a matching 'End If'." <-- BUT IT DOES!! WHY DOESN'TTHE DAMN SERVER SEE IT???

Discussion in 'ASP .Net' started by Neo Geshel, Jul 3, 2004.

  1. Neo Geshel

    Neo Geshel Guest

    It seems that there is somewhere where an IF statement will not nor ever
    function inside of an ASP.NET application.


    I am using IIS5 on Win2K. I have a web page that uses ASP.NET includes
    (an "@ resister" with the "Name:tag"). In the ascx include file I have a
    Sub Page_Load that contains an IF statement. I need the Sub Page_Load to
    exist inside the ascx file, because its results will be written to
    another part of the ascx's contents.

    It seems that the IF statement is incapable of functioning, as the
    server is claiming that the IF statement has no matching "End If", when
    in fact it does. I am using the following code:
    If ((Request.Browser.Platform = "WinNT") And
    (Request.Browser.Browser = "IE") And (Request.Browser.MajorVersion =
    "6")) Then
    strBrowserDetect = " <object id=""CTAdjust""
    codeBase=""http://www.microsoft.com/typography/clearadj.cab#version=1,0,0,1""

    classid=""CLSID:DE22A7AB-A739-4C58-AD52-21F9CD6306B7""
    VIEWASTEXT></object>" & vbCrLf & " <script type=""text/javascript""
    src=""/js/cleartype.js""></script>" & VbCrLf
    End If

    It produces the following error message:

    Compiler Error Message: BC30081: 'If' must end with a matching 'End If'.

    Source Error:

    Line 14: If ((Request.Browser.Platform = "WinNT") And
    (Request.Browser.Browser = "IE") And (Request.Browser.MajorVersion =
    "6")) Then
    Line 15: strBrowserDetect = " <object id=""CTAdjust""
    codeBase=""http://www.microsoft.com/typography/clearadj.cab#version=1,0,0,1""

    classid=""CLSID:DE22A7AB-A739-4C58-AD52-21F9CD6306B7""
    VIEWASTEXT></object>" & vbCrLf & " <script type=""text/javascript""
    src=""/js/cleartype.js""></script>" & VbCrLf
    Line 16: End If

    Source File: C:\Inetpub\Web Sites\Prairie West Wood
    Products\www\ssi\head.ascx Line: 14


    When I strip everything out of the IF statement, and put the following
    in the Sub:
    If Request.Browser.Platform = "WinNT" Then
    End If

    I get the following very bizarre error message:

    Compiler Error Message: BC30289: Statement cannot appear within a
    method body. End of method assumed.

    Source Error:

    Line 61: #End ExternalSource
    Line 62:
    Line 63: Public Sub New()
    Line 64: MyBase.New
    Line 65: If (ASP.head_ascx.__initialized = false) Then

    Source File: C:\WINNT\Microsoft.NET\Framework\v1.1.4322\Temporary
    ASP.NET Files\root\b8f35e90\23891c34\7ycfnybt.0.vb Line: 63



    COULD SOMEONE PLEASE TELL ME JUST WHAT THE **** IS GOING ON HERE??

    TIA
    ....Geshel
    --
    **********************************************************************
    My reply-to is an automatically monitored spam honeypot. Do not use it
    unless you want to be blacklisted by SpamCop. Please reply to my first
    name at my last name dot org.
    **********************************************************************
     
    Neo Geshel, Jul 3, 2004
    #1
    1. Advertising

  2. Neo Geshel

    hamking Guest

    Re: "'If' must end with a matching 'End If'." <-- BUT IT DOES!! WHY DOESN'T THE DAMN SERVER SEE IT???

    Neo Geshel <> wrote in message news:<W3oFc.939308$Pk3.322528@pd7tw1no>...
    > It seems that there is somewhere where an IF statement will not nor ever
    > function inside of an ASP.NET application.
    >
    >
    > I am using IIS5 on Win2K. I have a web page that uses ASP.NET includes
    > (an "@ resister" with the "Name:tag"). In the ascx include file I have a
    > Sub Page_Load that contains an IF statement. I need the Sub Page_Load to
    > exist inside the ascx file, because its results will be written to
    > another part of the ascx's contents.
    >
    > It seems that the IF statement is incapable of functioning, as the
    > server is claiming that the IF statement has no matching "End If", when
    > in fact it does. I am using the following code:
    > If ((Request.Browser.Platform = "WinNT") And
    > (Request.Browser.Browser = "IE") And (Request.Browser.MajorVersion =
    > "6")) Then
    > strBrowserDetect = " <object id=""CTAdjust""
    > codeBase=""http://www.microsoft.com/typography/clearadj.cab#version=1,0,0,1""
    >
    > classid=""CLSID:DE22A7AB-A739-4C58-AD52-21F9CD6306B7""
    > VIEWASTEXT></object>" & vbCrLf & " <script type=""text/javascript""
    > src=""/js/cleartype.js""></script>" & VbCrLf
    > End If
    >
    > It produces the following error message:
    >
    > Compiler Error Message: BC30081: 'If' must end with a matching 'End If'.
    >
    > Source Error:
    >
    > Line 14: If ((Request.Browser.Platform = "WinNT") And
    > (Request.Browser.Browser = "IE") And (Request.Browser.MajorVersion =
    > "6")) Then
    > Line 15: strBrowserDetect = " <object id=""CTAdjust""
    > codeBase=""http://www.microsoft.com/typography/clearadj.cab#version=1,0,0,1""
    >
    > classid=""CLSID:DE22A7AB-A739-4C58-AD52-21F9CD6306B7""
    > VIEWASTEXT></object>" & vbCrLf & " <script type=""text/javascript""
    > src=""/js/cleartype.js""></script>" & VbCrLf
    > Line 16: End If
    >
    > Source File: C:\Inetpub\Web Sites\Prairie West Wood
    > Products\www\ssi\head.ascx Line: 14
    >
    >
    > When I strip everything out of the IF statement, and put the following
    > in the Sub:
    > If Request.Browser.Platform = "WinNT" Then
    > End If
    >
    > I get the following very bizarre error message:
    >
    > Compiler Error Message: BC30289: Statement cannot appear within a
    > method body. End of method assumed.
    >
    > Source Error:
    >
    > Line 61: #End ExternalSource
    > Line 62:
    > Line 63: Public Sub New()
    > Line 64: MyBase.New
    > Line 65: If (ASP.head_ascx.__initialized = false) Then
    >
    > Source File: C:\WINNT\Microsoft.NET\Framework\v1.1.4322\Temporary
    > ASP.NET Files\root\b8f35e90\23891c34\7ycfnybt.0.vb Line: 63
    >
    >
    >
    > COULD SOMEONE PLEASE TELL ME JUST WHAT THE **** IS GOING ON HERE??
    >
    > TIA
    > ...Geshel


    I just had the same problem. For me it was cause I forgot to put the "End Sub"
    My if ... end if... worked
     
    hamking, Jul 21, 2004
    #2
    1. Advertising

  3. Neo Geshel

    Versteijn Guest

    Re: "'If' must end with a matching 'End If'." <-- BUT IT DOES!! WHY DOESN'T THE DAMN SERVER SEE IT???

    > I just had the same problem. For me it was cause I forgot to put the "End Sub"
    > My if ... end if... worked



    In my case (conversion from old asp to new asp.net page) there was an
    old </form> tag in the middle of the page. I used inline script, and
    some script was not 'found' or compiled or whatever until I removed
    this thing.

    If this was really the cause of this problem, why doesn't the compiler
    check this and display a more useful error message. It took me almost
    1 day :S

    Good luck,
    Regards,

    Freek Versteijn
     
    Versteijn, Aug 18, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. buran

    how can I get tthe referring page?

    buran, Mar 1, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    3,504
    buran
    Mar 1, 2004
  2. William
    Replies:
    2
    Views:
    1,739
    Kevin Spencer
    Jun 1, 2005
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,976
    Smokey Grindel
    Dec 2, 2006
  4. xiao

    Why tthe header is not declared ?

    xiao, Jul 20, 2008, in forum: C Programming
    Replies:
    17
    Views:
    474
  5. Neo Geshel

    "'If' must end with a matching 'End If'."

    Neo Geshel, Jul 3, 2004, in forum: ASP General
    Replies:
    0
    Views:
    139
    Neo Geshel
    Jul 3, 2004
Loading...

Share This Page