Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

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" 
        />
share|improve this answer
    
Thanks! That's what I needed. –  Kit Menke Aug 22 '11 at 19:57
    
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

@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;
        }
    }
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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