2

I have the requirement to not allow users to export my custom web part.

web part export

How do I disable/hide the Export menu option?

2

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" 
        />
  • You can also set this in the .Webpart file as a property, though obviously if someone edits the webpart, they can uncheck the checkbox. – Andy Burns Aug 23 '11 at 16:39
3

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.