N
Nick
I have been using the Server.Mappath method to get the physical directory
name so that I can create a connection string to my database.
When I include this in an ASPX file all works fine.
But I wanted to remove the code from my pages in put them either in code
behind or possibly an assembly.
I have to confess this is my first attempt at something like this and I am
having real problems.
For test purposes I created the following code
My Code in the ASPX page was:
Sub page_load
Response.Write(PathName())
End Sub
Function PathName() as string
Return Server.Mappath("/data")
End Function
This works absolutely fine
But when I transfer this to a code behind file and open the page I get the
error message
'PSolutions.DataAccess' is not a valid base class because it does not extend
class 'System.Web.UI.Page'.
In the ASPX file I have this code
<%@ page inherits="PSolutions.DataAccess" src="DataAccess.vb" %>
Sub Page_Load
Response.Write(PathName())
In the code behind file DataAccess.vb I have this code
Imports System
Imports System.Web
Namespace PSolutions
Public Class DataAccess
Public Function PathName() as String
Return HttpContext.Current.Server.Mappath("/Data") '<-- Got
this from the Microsoft web site.
End Function
End Class
End Namespace
End Sub
If I try to compile the vb file I get a message saying
name 'HttpContext' is not declared.
So at the moment I can't get anything to work.
Can anyone point me in the right direction.
As I said this is very new to me and I'm still learning so excuse any
amateur mistakes.
Many Thanks
Nick
name so that I can create a connection string to my database.
When I include this in an ASPX file all works fine.
But I wanted to remove the code from my pages in put them either in code
behind or possibly an assembly.
I have to confess this is my first attempt at something like this and I am
having real problems.
For test purposes I created the following code
My Code in the ASPX page was:
Sub page_load
Response.Write(PathName())
End Sub
Function PathName() as string
Return Server.Mappath("/data")
End Function
This works absolutely fine
But when I transfer this to a code behind file and open the page I get the
error message
'PSolutions.DataAccess' is not a valid base class because it does not extend
class 'System.Web.UI.Page'.
In the ASPX file I have this code
<%@ page inherits="PSolutions.DataAccess" src="DataAccess.vb" %>
Sub Page_Load
Response.Write(PathName())
In the code behind file DataAccess.vb I have this code
Imports System
Imports System.Web
Namespace PSolutions
Public Class DataAccess
Public Function PathName() as String
Return HttpContext.Current.Server.Mappath("/Data") '<-- Got
this from the Microsoft web site.
End Function
End Class
End Namespace
End Sub
If I try to compile the vb file I get a message saying
name 'HttpContext' is not declared.
So at the moment I can't get anything to work.
Can anyone point me in the right direction.
As I said this is very new to me and I'm still learning so excuse any
amateur mistakes.
Many Thanks
Nick