class with public shared members/methods not accessible in aspx page inline code

CarolinaDayHiker

New member
Joined
Feb 10, 2011
Messages
2
Programming Experience
5-10
Hey, first post here just signed up. I'm posting this question because I can't find the answer anywhere. This tells me it must be something small and obvious :p

I have a class with shared members and methods so data is accessible application wide.

I also have some in line VB code <% %> I use on a few aspx pages.

In code behind VS's intellisense shows the shared class and compiles with no problem.

In VB in line code on an aspx page I can't get the shared class to show in VS's intellisense and it won't compile - not declared.

I thought the shared members and methods would be available throughout. Does the aspx page need something for it to "see" the class?

The same problem also exists with a module. Can't access a module's members from inline code <% ... %>

thanks for all your help

edit: I should add that none of my *.vb code is in the app_code folder. All my classes are in the main folder and when I publish the site they are all converted into a dll so that none of my code exists as a .vb file on the server. Only the global.asax file is in the app_code folder. Unsure how that would affect my problem.
 
Last edited:
Ok, got it resolved. It was simple. ASPX pages need the namespace imported.

<%@ Import Namespace="MyNamespace" %>

and <% MyClass.Method() %>

OR - without the import you could use

<% MyNamespace.MyClass.Method() %>

any ideas which may be better?
 
Back
Top