can we use "Server.MapPath" in non webpage file ?

T

Tee

Hi,

I am currently using Server.MapPath in my aspx files, but because of I am
using it more than once, I would like to move these code away from aspx and
make it as a public function inside Module, but I am having problem with it.
As "Server.MapPath" is not allow in other .vb file ... can anyone help with
this ? or if we really can't make it, is there any other way could do it ?


Thanks,
Tee
 
J

John Saunders

Tee said:
Hi,

I am currently using Server.MapPath in my aspx files, but because of I am
using it more than once, I would like to move these code away from aspx and
make it as a public function inside Module, but I am having problem with it.
As "Server.MapPath" is not allow in other .vb file ... can anyone help with
this ? or if we really can't make it, is there any other way could do it ?

Your problem isn't that "Server.MapPath" is not allowed in another .vb file.
Your problem is that "Server" is not defined in that other .vb file.

When you reference "Server" in your .aspx page, you're really referencing
"Page.Server", which is a copy of Page.Context.Server. The latter can also
be referenced in your other .vb file as HttpContext.Current.Server.
 
T

Tee

OK, now I get it, thanks


John Saunders said:
?

Your problem isn't that "Server.MapPath" is not allowed in another .vb file.
Your problem is that "Server" is not defined in that other .vb file.

When you reference "Server" in your .aspx page, you're really referencing
"Page.Server", which is a copy of Page.Context.Server. The latter can also
be referenced in your other .vb file as HttpContext.Current.Server.
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top