1

I'm trying to have an image show up within a webpart based on the authorization group of a user.

Is there a way to assign a specific audience to an image within a WebPart rather then the entire WebPart?

Thanks!

1
  • what do you mean with image show up based within a webpart ? what's the type of this web part ? by the way, the audience applied at the entire web part. Commented Sep 20, 2016 at 12:59

1 Answer 1

1

You can use SPSecurityTrimmedControl in webpart design file,

<Sharepoint:SPSecurityTrimmedControl runat=”server” Permissions=”ViewPages”>
//Only users with ViewPages permissions will be able to see this content.
<img src="test.gif" alt="test" height="42" width="42">
</SharePoint:SPSecurityTrimmedControl>

SPSecurityTrimmedControl which performs the security trimming of the child controls inside it. Just include our control inside this control and it will be displayed or hidden based on the permission specified.

Here is detail example http://www.c-sharpcorner.com/UploadFile/40e97e/security-trimmed-control-in-sharepoint-2013/

2
  • Thanks! This is very useful. Instead of displaying the image based on a specific permission, is there a way to have it displayed using the group ID?
    – Fred
    Commented Sep 20, 2016 at 14:39
  • We can not add sharepoint group in SPSecurityTrimmedControl. this thread may help you. sharepoint.stackexchange.com/questions/112337/… Commented Sep 20, 2016 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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