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