Error on page load "cannot use paretheses when calling a sub"

Discussion in 'C#' started by Sleeping Troll, Apr 13, 2008.

  1. #1
    Error refers to this line:

    <area shape="poly" coords="123,35,108,43,108,26,123,35" alt="" onClick="GetImg('F','Package')"/>

    Anybody know what's up?
     
    Sleeping Troll, Apr 13, 2008 IP
  2. InfoSmith

    InfoSmith Peon

    Messages:
    884
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    GetImg is a function, you need paste the source code here
     
    InfoSmith, Apr 13, 2008 IP
  3. Sleeping Troll

    Sleeping Troll Peon

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    <script type="text/vbscript">
    Sub GetImg(Dir,Spin)
    Select Case Dir
    Case "F"
    Select Case Spin
    Case "Package"
    Response.redirect("Panel.asp?MenuItem=" + MenuItem + "&RecNum=" + RecNum + "&Dir=F&Spin=Package" )
    Case "Size"
    Response.redirect("Panel.asp?MenuItem=" + MenuItem + "&RecNum=" + RecNum + "&Dir=F&Spin=Size")
    Case "Flavor"
    Response.redirect("Panel.asp?MenuItem=" + MenuItem + "&RecNum=" + RecNum + "&Dir=F&Spin=Flavor")
    End Select
    Case "B"
    Select Case Spin
    Case "Package"
    Response.redirect("Panel.asp?MenuItem=" + MenuItem + "&RecNum=" + RecNum + "&Dir=B&Spin=Package")
    Case "Size"
    Response.redirect("Panel.asp?MenuItem=" + MenuItem + "&RecNum=" + RecNum + "&Dir=B&Spin=Size")
    Case "Flavor"
    Response.redirect("Panel.asp?MenuItem=" + MenuItem + "&RecNum=" + RecNum + "&Dir=B&Spin=Flavor")
    End Select
    End Select
    End Sub
    </script>
     
    Sleeping Troll, Apr 13, 2008 IP
  4. Sleeping Troll

    Sleeping Troll Peon

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The error means you cannot use parentheses when calling a sub!
    The fix is to remove the parentheses!
    <area shape="poly" coords="123,35,108,43,108,26,123,35" alt="" onClick="GetImg 'F','Package'"/>
    Geez, that is the craziest thing I have ever come across!
     
    Sleeping Troll, Apr 13, 2008 IP
  5. vpguy

    vpguy Guest

    Messages:
    275
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    What's even crazier is how you have mixed client-side script with server-side script.

    1. The script block is of type text/vbscript without a runat=server, meaning that it will only be executed by Internet Explorer clients.

    2. The area element has no runat=server attribute, so its onclick event will call the client-side VBScript code (in IE only; it will error/do nothing in other browsers).

    3. The client-side VBScript code contains Response.Redirect statements, which is a server-side ASP command.

    Does the code actually work? :confused:
     
    vpguy, Apr 14, 2008 IP