0

Here I have an abstract class for my master pages

public abstract class BaseMaster2 : System.Web.UI.MasterPage
{
    public abstract List<string> ElementIdsToHideForPrint
    {
        get;
        set;
    }
}

And I have one of my master master page :

public partial class Template_Base2 : BaseMaster2
{
    private List<string> _elementsIdsToHide;
    public override List<string> ElementIdsToHideForPrint
    {
        get { return _elementsIdsToHide; }
        set { _elementsIdsToHide = value; }
    }
}

Everything works fine like that on my test server but if I put all this on the production server I get a runtime error. I tried to put my code step by step on the server to see what throws this error and it seems that all works without the word override in the master page like

public List<string> ElementIdsToHideForPrint { ... }

Any idea why is this runtime error thrown?

ps: I shorted the code here to make it easier to read.

I initialize in my page that includes that master page:

protected void Page_Load(object sender, EventArgs e)
{
    SetElementsIdsForPrintHideShow();
}

private void SetElementsIdsForPrintHideShow()
{
    BaseMaster2 _master = this.Master as BaseMaster2;
    List<string> _ids = new List<string>();

    //hide
    _ids.Add("btnPrinterFriendly"); //action buttons top 
    _master.ElementIdsToHideForPrint = _ids;
}
Greg
  • 640
  • 5
  • 11
  • 23
  • I have "RunTime Error" – Greg Oct 24 '13 at 13:30
  • OK, that's not very specific. You need to do some more debugging and find out what the error is. – tnw Oct 24 '13 at 13:33
  • possible duplicate of [Overriding fields or properties in subclasses](http://stackoverflow.com/questions/326223/overriding-fields-or-properties-in-subclasses) – Yosi Dahari Oct 24 '13 at 13:35
  • @tnw It's hard for me to debug since the error occurs only the live server. On the test server where I can debug, I don't have any error. – Greg Oct 24 '13 at 14:10
  • @Yosi It seems that I follow the same code as the link you gave me, overriding an abstract property. And I don't override it anywhere else, just in this class. – Greg Oct 24 '13 at 14:13
  • You should have logging in place that is able to capture this and log it. – tnw Oct 24 '13 at 14:47

0 Answers0