Thursday, October 18, 2012

SharePoint 2010 Web Part Error: A Web Part or Web Form Control on this page cannot be displayed or imported. You don’t have Add and Customize Pages permissions required to perform this action

 

I deployed  a SharePoint 2010 on a customer’s system. At first, everything worked OK when users with elevated privileges were testing the part. However, soon after read-only users started experiencing the above error. If a user’s privilege was escalated to “Designer”, it would start working again.

The solution to the problem is to find the SharePointProjectItem.spdata file associated with the web-part and change the IsSafeAgainstScript to true in the <SafeControl..> element.

For Example:

<SafeControls>
    <SafeControl Name="SafeControlEntry1"
        Assembly="$SharePoint.Project.AssemblyFullName$"
        Namespace="Medhat.Ca.MyWebpart"
        TypeName="*"
        IsSafe="true"
        IsSafeAgainstScript="true" />
</SafeControls>

The explanation for this error is that users with privileges below "Design” are not allowed to add web-parts into web pages.

No comments:

Post a Comment