locked
Cannot find my Custom Classes RRS feed

  • Question

  • User177125058 posted

     Hi,

     

    I have written a VB class that i've imported into my ASP.NET web app using VS2005.

    However I cannot use the class in my aspx CodeFile, nor import it's namespace.

    Please advise.

    Here is the skeleton class:

     

    1    Imports System.Data.OleDb
    2    Imports System.Data
    3    Namespace MyNamespace
    4        
    5        Public Class MyClass
    6    
    7        End Class
    8    End Namespace
    9    
    
      
    Monday, September 8, 2008 1:10 PM

All replies

  • User-22218653 posted

     i have tested it ..... works fine :P

     

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="test" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        
        </div>
        </form>
    </body>
    </html>
    
       
    Imports myspace
    
    Partial Class test
        Inherits System.Web.UI.Page
        Dim aa As Class1
    
    End Class
    

     custom class in app_code folder

     

    Imports Microsoft.VisualBasic
    Namespace myspace
        Public Class Class1
    
        End Class
    
    End Namespace
    
      
    Monday, September 8, 2008 1:50 PM
  • User899981202 posted

    If the class is a DLL, you got to add a reference to your project.
    (Right-click your project in your project map, and then click 'Add reference...' in the appearing menu.)

    Monday, September 8, 2008 3:05 PM
  • User177125058 posted

     I have the exact same structure as yours, yet my Partial class cannot find the namespace.

    No Idea why this is happening.

    Monday, September 8, 2008 3:06 PM
  • User177125058 posted

    If the class is a DLL, you got to add a reference to your project.
    (Right-click your project in your project map, and then click 'Add reference...' in the appearing menu.)

     My Class is a .vb file added to the App_Data folder. None of my other Code files for the aspx pages recognize the namespace.

    Monday, September 8, 2008 3:13 PM
  • User177125058 posted

    My Class is a .vb file added to the App_Data folder.

     

     Which was my problem. I wasn't aware there was an App_Code folder as well. And at first didn't notice it.

    Added the App_Code folder and put the classes in there, now everything works fine.

    Thanks people! (and pardon my ignorance.)

    Monday, September 8, 2008 3:19 PM
  • User899981202 posted


    1    Imports System.Data.OleDb
    2    Imports System.Data
    3    Namespace MyNamespace
    4   
       
    5        Public Class MyClass
    6   
    7        End Class
    8    End Namespace


    Is the namespace of your class another than the namespace of your application?

    If yes, you got to import that namespace ("imports MyNamespace") or write "MyNamespace.MyClass".

    Tuesday, September 9, 2008 3:16 AM
  • User177125058 posted

     No my class has it's own namespace and I did import it.

    But my mistake was putting it in the App_Data folder instead of the App_Code folder.

    Tuesday, September 9, 2008 9:05 AM