I have the requirement to not allow users to export my custom web part.
How do I disable/hide the Export menu option?
See the WebPartExportMode Enum. You will set this enum when adding the user control to the page. You can allow no properties to be exported.
<aspSample:TextDisplayWebPart
runat="server"
id="textwebpart"
title = "Text WebPart"
ExportMode="None"
/>
@Tim's answer was what I needed. I ended up using an override and I have a Web Part Property (WPPAllowExport
) that controls whether or not to allow the export.
public override System.Web.UI.WebControls.WebParts.WebPartExportMode ExportMode
{
get
{
if (WPPAllowExport)
{
return base.ExportMode;
}
return System.Web.UI.WebControls.WebParts.WebPartExportMode.None;
}
set
{
if (WPPAllowExport)
{
base.ExportMode = value;
}
else
{
base.ExportMode = System.Web.UI.WebControls.WebParts.WebPartExportMode.None;
}
}
}