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;
}
4

0 回答 0