How can I use a static class that is placed in another folder
-
Hi I don't know how I can use a static class, that is placed in another folder from where I'm calling it. I have the code below in default.aspx.cs, witch is placed under the folders Test1/Test2 (\WebSite12\Test1\Test2\Default.aspx.cs)
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection s = Databas.con;
}
}The class, Databas.cs is placed in the root of the website. I get the error The name 'Databas' does not exist in the current context. I have the same problem with the global.asax, whitch is also placed in the root. Please Help Fia
-
Hi I don't know how I can use a static class, that is placed in another folder from where I'm calling it. I have the code below in default.aspx.cs, witch is placed under the folders Test1/Test2 (\WebSite12\Test1\Test2\Default.aspx.cs)
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection s = Databas.con;
}
}The class, Databas.cs is placed in the root of the website. I get the error The name 'Databas' does not exist in the current context. I have the same problem with the global.asax, whitch is also placed in the root. Please Help Fia
The root is the wrong place to put it, in every way. There's a folder for your application code, it has to go in there. Why would you want to return a SQLConnection into the presentation layer ?
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
Hi I don't know how I can use a static class, that is placed in another folder from where I'm calling it. I have the code below in default.aspx.cs, witch is placed under the folders Test1/Test2 (\WebSite12\Test1\Test2\Default.aspx.cs)
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection s = Databas.con;
}
}The class, Databas.cs is placed in the root of the website. I get the error The name 'Databas' does not exist in the current context. I have the same problem with the global.asax, whitch is also placed in the root. Please Help Fia
Hi, thanks for your answer I put the Databas.cs in the folder App_Code, but I couldn't use it anyway. Is there something else I have to do, then writing SqlConnection s= Databas.con. I have it like this because I don't want to write the connection string for every page. I have trouble with using the global.asax also, should that file also be placed in App_Code. But as I said I can't use it anyway. Please Help Fia
-
Hi, thanks for your answer I put the Databas.cs in the folder App_Code, but I couldn't use it anyway. Is there something else I have to do, then writing SqlConnection s= Databas.con. I have it like this because I don't want to write the connection string for every page. I have trouble with using the global.asax also, should that file also be placed in App_Code. But as I said I can't use it anyway. Please Help Fia
-
Hi Sorry, I placed the Databas.cs file in the App_Data folder, but now I have it in the App_Code folder and it's working, thanks. But what about global.asax. That file is placed in the root of the website, but I can't use it anyway. Fia
What do you mean you can't use it ? What do you think it's for ?
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
The root is the wrong place to put it, in every way. There's a folder for your application code, it has to go in there. Why would you want to return a SQLConnection into the presentation layer ?
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.