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. I can't see other pages from the same folder

I can't see other pages from the same folder

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netquestion
4 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.
  • C Offline
    C Offline
    CWIZO
    wrote on last edited by
    #1

    I am trying to understand how all this referencing works in ASP.NET 2.0 but it seems that this is not written anywhere. I have a ASP.NET 2.0 application. All the pages are in the root folder. All pages inherits from a class (BasePage) that is inside App_Code (this class inherits the Page class). I also have a MasterPage which all the pages use. I don't understand why I can't access backend class of aspx page A from aspx page B. They are in the same namespace (all the stuff is in the same namespace) and in the same folder but I can't access it. I only see classes that are in the App_Code folder, the MasterPage and a control that I have registered in the aspx file. And I can't "see" apsx pages from classes that are inside App_Code too. What's the deal here? You could "see" other pages in ASP.NET 1.1 why can't I in 2.0? I would really like to know this, because I would like to have a reference to a MasterPage from my PageBase class (inside App_Code) (if I move the MasterPage.master.cs file to App_Code the page still works but I can't reference controls that are on the MasterPage.master from MasterPage.master.cs).

    -------------------------------------------------------- My portfolio & development blog Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!

    M 1 Reply Last reply
    0
    • C CWIZO

      I am trying to understand how all this referencing works in ASP.NET 2.0 but it seems that this is not written anywhere. I have a ASP.NET 2.0 application. All the pages are in the root folder. All pages inherits from a class (BasePage) that is inside App_Code (this class inherits the Page class). I also have a MasterPage which all the pages use. I don't understand why I can't access backend class of aspx page A from aspx page B. They are in the same namespace (all the stuff is in the same namespace) and in the same folder but I can't access it. I only see classes that are in the App_Code folder, the MasterPage and a control that I have registered in the aspx file. And I can't "see" apsx pages from classes that are inside App_Code too. What's the deal here? You could "see" other pages in ASP.NET 1.1 why can't I in 2.0? I would really like to know this, because I would like to have a reference to a MasterPage from my PageBase class (inside App_Code) (if I move the MasterPage.master.cs file to App_Code the page still works but I can't reference controls that are on the MasterPage.master from MasterPage.master.cs).

      -------------------------------------------------------- My portfolio & development blog Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, This is the behavior by design of the ASP.NET 2.0 to support the dynamic compiling. In this case, you may consider the @ Reference directive to link to the class of the web page or web user control, and the MasterType for the master page. Another option is to use the Web Project 2005 instead of the built-in web site template to create an ASP.NET application.

      C 1 Reply Last reply
      0
      • M minhpc_bk

        Hi there, This is the behavior by design of the ASP.NET 2.0 to support the dynamic compiling. In this case, you may consider the @ Reference directive to link to the class of the web page or web user control, and the MasterType for the master page. Another option is to use the Web Project 2005 instead of the built-in web site template to create an ASP.NET application.

        C Offline
        C Offline
        CWIZO
        wrote on last edited by
        #3

        So by using the @Reference I would have all my aspx.cs files in App_Code and aspx files would reference those classes and I would have to ommit the CodeFile parameter, right?

        -------------------------------------------------------- My portfolio & development blog Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!

        M 1 Reply Last reply
        0
        • C CWIZO

          So by using the @Reference I would have all my aspx.cs files in App_Code and aspx files would reference those classes and I would have to ommit the CodeFile parameter, right?

          -------------------------------------------------------- My portfolio & development blog Q:What does the derived class in C# tell to it's parent? A:All your base are belong to us!

          M Offline
          M Offline
          minhpc_bk
          wrote on last edited by
          #4

          Actually, the Reference[^] directive provides you with an way to link a web page/user control to the web page/user control that contains this directive. For example, if you want to call the class of the Page1.aspx from the Page2.aspx, you would normally use the Reference directive to get reference to the Page1.aspx (the CodeFile attribute is still being used in this case). To get reference to the web page/user control's classes from the classes put in the App_Code folder, putting the soure files in the App_Code, ommiting the CodeFile attribute (but the Inherits attribute is still) is an option. Another option is that you can define the base class for the web page with custom properties so that you can pass the current page to this base class before calling its members.

          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