In every form we derive from FormBaseControl, we have the following code. I’m sure there is a better way to type the controller object than this, but at the moment we have it included in every page. In the example below, base.Controller is of type BaseController, from which ExportController derives. I find duplication of this code in each derivation of FormBaseControl to not smell right, but I can’t quite figure a way of righting it.
private ExportController MyController { get { return base.Controller as ExportController; } } protected void Page_Load(object sender, EventArgs e) { base.Controller = new ExportController(WebNavigator.Current);
Can you not use a generic class to fix this?
I.e. instead of:
in the derived class.
Put:
in the base class, and turn the base class into a generic class
BaseController<T>