Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. How can I use a static class that is placed in another folder

How can I use a static class that is placed in another folder

Scheduled Pinned Locked Moved ASP.NET
helpdesignquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fiaolle
    wrote on last edited by
    #1

    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

    C F 2 Replies Last reply
    0
    • F fiaolle

      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

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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.

      F 1 Reply Last reply
      0
      • F fiaolle

        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

        F Offline
        F Offline
        fiaolle
        wrote on last edited by
        #3

        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

        F 1 Reply Last reply
        0
        • F fiaolle

          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

          F Offline
          F Offline
          fiaolle
          wrote on last edited by
          #4

          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

          C 1 Reply Last reply
          0
          • F fiaolle

            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

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            • C Christian Graus

              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.

              F Offline
              F Offline
              fiaolle
              wrote on last edited by
              #6

              Hi What I'm trying to say it that it doesn't find it, so I can't use it in the code behind. Fia

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups