I had an interesting issue when I tried simplifying some code today and I'm not sure why this would happen.
I have my ApplicationBasePage that includes references to all my business objects. So far, so good. During the Page_Init event for each of my pages, I perform a few tasks related to the data layer (setting a Db2DataSourceItem attribute on the page) and initializing business object datasource keys (by calling a method in my Global.asax file called InitializeDataSourceKeys() that takes an ApplicationBasePage typed parameter).
I had a logic issue and needed to change the order (InitializeDataSourceKeys() needed to be called before I set my Db2DataSourceItem object). Thankfully, I only had 8 pages, but I thought it might be better to put the complete contents of the page event into a method in ApplicationBasePage so I wouldn't have to change it for every page in the future.
So I started moving it to a method in App_Data/ApplicationBasePage.cs called InitializeDataConnections(out ConnObj). Problem is, it wouldn't even compile the page.
I received an error that it couldn't locate the Db2 namespace in MicroFour.Strataframe.Data. It worked fine in my page, but not once I moved it to ApplicationBasePage.cs. I checked to make sure I had a reference to it for my Web Application Project -- and I did. I also checked to make sure I had a "using" statement at the top of ApplicationBasePage.cs -- and I did:
using MicroFour.Strataframe.Data;
using MicroFour.Strataframe.Data.Db2;
I kept getting the error. I ended up just moving everything back to the Page_Init event and it works fine. But I'm wondering why it wouldn't work with the code placed in ApplicationBasePage.
Any ideas? Do I need to do something different to reference DataSourceItem objects in ApplicationBasePage?
Thanks!