Errors appear in vb file only

Discussion in 'ASP .Net' started by DesCF, Dec 17, 2006.

  1. DesCF

    DesCF Guest

    Below is a section from my aspx web page. If I create the same but place
    the function GetPhotos() in a separate vb file I get the following errors
    underlined in blue:

    List(Of String) - Type 'List' is not defined
    Directory - Name 'Directory' is not declared
    Path - Name 'Path' is not declared

    Does anyone know why this is? Have I missed something obvious?



    <%@ Page Language="VB" %>
    <%@ Import Namespace="System.IO" %>
    <%@ Import Namespace="System.Collections.Generic" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <script runat="server">

    Public Function GetPhotos() As List(Of String)
    Dim photos As New List(Of String)()
    Dim photoPath As String = MapPath("~/Photos")
    Dim files As String() = Directory.GetFiles(photoPath)
    For Each photo As String In files
    photos.Add("~/Photos/" + Path.GetFileName(photo))
    Next
    Return photos
    End Function



    --
    Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
     
    DesCF, Dec 17, 2006
    #1
    1. Advertising

  2. DesCF

    DesCF Guest

    Ok, I've sorted it out. I needed to put the following 2 lines at the top
    of the vb file:

    Imports System.IO
    Imports System.Collections.Generic




    On Sun, 17 Dec 2006 11:17:25 -0000, DesCF <> wrote:

    > Below is a section from my aspx web page. If I create the same but
    > place the function GetPhotos() in a separate vb file I get the following
    > errors underlined in blue:
    >
    > List(Of String) - Type 'List' is not defined
    > Directory - Name 'Directory' is not declared
    > Path - Name 'Path' is not declared
    >
    > Does anyone know why this is? Have I missed something obvious?
    >
    >
    >
    > <%@ Page Language="VB" %>
    > <%@ Import Namespace="System.IO" %>
    > <%@ Import Namespace="System.Collections.Generic" %>
    >
    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    > "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    > <script runat="server">
    >
    > Public Function GetPhotos() As List(Of String)
    > Dim photos As New List(Of String)()
    > Dim photoPath As String = MapPath("~/Photos")
    > Dim files As String() = Directory.GetFiles(photoPath)
    > For Each photo As String In files
    > photos.Add("~/Photos/" + Path.GetFileName(photo))
    > Next
    > Return photos
    > End Function
    >
    >
    >




    --
    Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
     
    DesCF, Dec 17, 2006
    #2
    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. Rob Zoldan

    HTML pages only partially appear

    Rob Zoldan, Nov 5, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    378
    Kevin Spencer
    Nov 6, 2003
  2. Mark Goldin

    Errors, errors, errors

    Mark Goldin, Jan 17, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    1,027
    Mark Goldin
    Jan 17, 2004
  3. keithb
    Replies:
    2
    Views:
    8,068
    keithb
    Jun 7, 2006
  4. rockdale
    Replies:
    3
    Views:
    3,320
    rockdale
    Nov 3, 2006
  5. Micromanaged
    Replies:
    0
    Views:
    141
    Micromanaged
    Nov 1, 2004
Loading...

Share This Page