2
Vote

XML web part throws exception when added directly to master page

description

When XML web part is added to master page/page layout outside the web part zone the web part's OnPreRender method throws NullReferenceException when it tries to reference it's WebPartManager. Possible Workaround that hides the base class' WebPartManager property:
protected new WebPartManager WebPartManager
{
get
{
    WebPartManager manager;
    if (base.WebPartManager != null)
    {
        manager = base.WebPartManager;
    }
    else
    {
        manager = WebPartManager.GetCurrentWebPartManager(this.Page);
    }
 
    return manager;
}
}

comments