I'm working on creating a new base class for an asp.net app in order to create my own version of a strongly typed view from MVC. The app itself is NOT a MVC app though. Below is the basis of my custom class.
public class BasePage<T> : Page where T : IPageInfo
{
public BasePage()
{
this.MyPageInfo = IoC.GetInstance<IPageInfo>(); //pseudo-code to populate a property.
}
}
When I add a new WebForm page to my application, I change the "inherits" attribute of the Page directive to point to this BasePage class instead of the typical code-behind class in the same manner as ASP.Net MVC strongly typed views. Below is an example of the page directive.
<%@ Page language="C#" inherits="MyApp.Core.BasePage<MyApp.Content.Search>"%>
In the above directive, MyApp.Content.Search class implements the IPageInfo interface that the BasePage needs to satisfy the generic type constraint.
Everything compiles fine but when I browse to the page I get the error Could Not Load Type
. I cracked open the MVC 2 assembly to look at how ViewPage was done and it appears to be the same basic structure. I looked around the web and the general recommendation for this error with MVC was to remove and readd the reference to MVC. This would be great if I was using MVC; however both my BasePage class and my Search classes are in the same assembly. I have been using fully qualified names (as shown) as well.
Anyone have any idea on what I could attempt to get this to work?
Thanks