November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Hi Paul,
I did it like this:
[GuiPlugIn(Area = PlugInArea.EditPanel)]
public class RemoveXFormTab : ICustomPlugInLoader
{
public PlugInDescriptor[] List()
{
// Hook LoadComplete-event on EditPanel page
var editPanel = HttpContext.Current.Handler as EPiServer.UI.Edit.EditPanel;
if (editPanel != null)
{
editPanel.LoadComplete += new EventHandler(EditPanelLoadComplete);
}
// Never return a plugin - we don't want to add tabs.
return new PlugInDescriptor[] { };
}
protected void EditPanelLoadComplete(object sender, EventArgs e)
{
// Find the TabStrip with id = "actionTab"
var actionTabStrip = FindControl<TabStrip>(sender as Control, "actionTab");
if (actionTabStrip == null) return;
// Loop trough all tabs and locate the XFormPostings tab to hide it
foreach (Tab tab in actionTabStrip.Controls)
{
if (tab.PlugInID == 0) continue;
PlugInDescriptor desc = PlugInDescriptor.Load(tab.PlugInID);
if(desc != null && desc.PlugInType == typeof(EPiServer.UI.Edit.XFormPostings))
{
tab.Visible = false;
}
}
}
// Try to locate control of type T with ID==id
// Recurses into each childcontrol until first match is found
protected T FindControl<T>(Control control, string id) where T : Control
{
var controlTest = control as T;
if (null != controlTest && (null == id || controlTest.ID.Equals(id)))
{
return controlTest;
}
foreach (Control c in control.Controls)
{
controlTest = FindControl<T>(c, id);
if (null != controlTest)
{
return controlTest;
}
}
return null;
}
}
I am trying to hide the XForms Data Tab in Edit Mode based on certain criteria. My problem is that I can't find the tab in the controls collection using the following code:
I am using this blog http://world.episerver.com/Blogs/Eric-Vanderfeesten/Dates/2013/4/EditPanel-Manager/ as inspiration