Problem referencing other classes from ASP.NET code behind class

G

Guest

I have a page called admin.aspx and it uses admin.aspx.cs as it's code behind
file.
When developing the application on my localhost using VS.NET i reference
thsi file using codebehind="admin.aspx.cs". I now have to upload it to a
production server which i have no control over and has no bin directory (and
i cannot create one) to place the project dll assemblies in to.

I have now changed the file to use the src attricbute so the files are
compiled on the fly using JIT and do not require the dll:

<%@ Page language="c#" src="admin.aspx.cs" AutoEventWireup="false"
Inherits="vox.admin" %>

When the admin.aspx is called it runs but I get the followign error:

Compiler Error Message: CS0234: The type or namespace name 'dataLayerAccess'
does not exist in the class or namespace 'vox' (are you missing an assembly
reference?)

Source Error:
line 27: private vox.dataLayerAccess db;

The problem occurs on my localhost as well if i remove the bin directory.
The problem is that the code behind class cannot find other classes which are
in the same directory. Is there a way of giving the admin.aspx.cs class a
reference to the location of where the other class is vox.dataLayerAccess.cs
as admin.aspx can find admin.aspx.cs using src=acmin.aspx.cs?

Note i have tried to remove the namespace vox and the error still occurs.
Any ideas would be apprciated as i cannot get a bin directory on the web
server i am deploying too.

Thanks

Ian
 
I

Iain Norman

I have a page called admin.aspx and it uses admin.aspx.cs as it's code behind
file.
When developing the application on my localhost using VS.NET i reference
thsi file using codebehind="admin.aspx.cs". I now have to upload it to a
production server which i have no control over and has no bin directory (and
i cannot create one) to place the project dll assemblies in to.

Ask them to make a bin folder, can't see that would put many people
out. You have FTP access but can't create folders?

I
 
G

Guest

I can create folders but the directory is not setup as a virtual directory so
it the files when executed will not look in the bin directory created. Thats
why i dont want to use a bin directory and want to use src as the
administartor will not change the server.
 
J

Joshua Flanagan

If your application folder is not setup as a virtual directory, you will
likely fall into many more problems than this.

As you seem to know, using src= instead of codebehind= in the @Page
directive should solve the immediate problem for you.

Joshua Flanagan
http://flimflan.com/blog
 
P

Patrick Olurotimi Ige

Ian maybe use inline coding..
For example use WebMatrix and that could solver ur problem for now.
Hope it helps!
Patrick
 
Joined
Sep 14, 2006
Messages
6
Reaction score
0
Here is the solution

1. Add @Register tag in the aspx and then you would be able to access that particular usercontrol in codebehind.
2. Try adding @import in aspx and then you should be able to access that codebehind in your codebehind.
3. Try keeping such common class in app_code so that it is accessible.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top