Results 1 to 3 of 3

Thread: variable undeclared in included file.

  1. #1
    Join Date
    Oct 2008

    Unhappy variable undeclared in included file.

    I have two files. (This is a simplified example)

    The first file declared variables - the second outputs the variables.

    The problem is that myArray is 'undeclared' when file2.aspx tries to use it. However varName is working fine.

    If I declare and populate myArray in the same way in file2.aspx it also works fine.

    Can anyone shed any light on the problem?

    'declare variable
    varName = "hello"
    'declare array
    Dim myArray(2) As String
    myArray(0) = "0"
    myArray(1) = "1"
    myArray(2) = "2"
    <!--#include file="file2.aspx"-->
    'output name variable
    'Loop through array and output results.
    For i = 0 To 2
    Thanks for your help.

  2. #2
    Join Date
    Jan 2009
    Well, first (bangs his head on the desk) Why on earth in .net are you using include files. Classic asp ok. .net, no way

    Second (bangs his head on the desk) why are using using in line code in .net Classic asp ok. .net, no way

    Sorry if this answer sound snippy, but .net even asp.net is an object oriented language, when you are using inline code then you are not defining your classes and so on so what asp.net does is create those classes for you and compiles your pages for you however it compiles them in temp class names that you do not know what they are going to be. So anyway it looks like you are trying very hard not to give up classic asp, which really doesn't work anymore.

    So each and every page is compiled separately into its own class, this includes your include files. So one include can not reference another include or anything in it.

    Instead what you would need to do is use code behind, name your classes and where you want shared code create actual class files.

  3. #3
    Join Date
    Aug 2005
    The Garden State
    <!--#include style is for server side includes, .net doesn't parse them as part of the same request, they're parsed as separate requests.
    Acceptable Use | SQL Forum FAQ | celery is tasteless | twitter

    celery is tasteless - currently needing some UI time

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center