Set Audience targeting on a web part programmatically#

Just received some lines of code for my colleague Wouter about setting audience targeting on a web part programmatically. I thought sharing would be useful because there is very little documentation out there...

SPLimitedWebPartManager mgr = webMS.GetLimitedWebPartManager("default.aspx", System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);

SPLimitedWebPartCollection col = mgr.WebParts;

webparts[0].AuthorizationFilter = ";;;;" + "ROLE 1" + "," + "ROLE 2";

mgr.SaveChanges(webparts[0]);

In this case the first web part gets the role1 and role2 audiences. Checking the MSDN library it says: "Gets or sets an arbitrary string to determine whether a Web Part is authorized to be added to a page". Hmm can someone explain this a little more?

Tuesday, January 08, 2008 2:57:14 PM UTC #     | 

 

All content © 2012, Mart Muller
On this page
This site
Calendar
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
Archives
Sitemap
Disclaimer

Powered by: newtelligence dasBlog 1.9.7174.0

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts