locked
SharePoint 2010 Personalized WebParts RRS feed

  • Question

  • hi All,

    Currently I have a requirement to create igoogle like interface with sharepoint.for which i am having webpartzone set to attribute AllowPersonalizable="true" and allowing user to selects and add the WebPart from the popup, opening when user clicks on add a WebPart link. programatically i am adding  the webpart having set its personalizedscope set to user to the required webpartzone.

    This allows webpart to be visible and configurable only to the user who has added it even the admin of the site cannot see or configure or delete the webpart added by the other users.

    But I have a requirement that Admin of the site should have the ability to atleast delete the personalized webpart added by the particular user.Please let me know what can be done in this case ?? this will be of greate help i have google this requirement but of no help.I am not able to find any option avaliable out of box or programatically from which i can delete the personalized webparts for the particular user.

     

    but in addition to it i wan

    Wednesday, March 30, 2011 6:40 PM

Answers

  • Hi ,

    I have got the soulution for the problem atlast, we can delete the personalized webparts for particular users programatically by impersonalting the SharePoint user getting the SPSite object in their context and then deleting the personqalized webparts

    :)

    • Marked as answer by Wayne Fan Tuesday, April 5, 2011 8:46 AM
    Sunday, April 3, 2011 12:57 PM

All replies

  • Do you want the admin to delete the webpart entirely or just from their page, and let other people still have that webpart?
    Wednesday, March 30, 2011 6:53 PM
  • Actually I want both the options for the admin

    he should have the ability to webpart entirely from the page and should have the ability to delete other people webparts also.

    Thursday, March 31, 2011 4:53 PM
  • I dont know of a way to delete it form just that users page.  But the admin can easily go to the web part gallery and delete it from there. at that point it would not be availiable to anyone.
    Thursday, March 31, 2011 5:56 PM
  • Try the code below it should give you all the webpart with personalization scope to User. Then you can loop throught all of them and delete/edit webpart you dont need.

    using (SPSite site = new SPSite("http://localhost"))
    {
    using (SPWeb rootWeb = site.OpenWeb())
    {
    SPLimitedWebPartManager wm = rootWeb.GetLimitedWebPartManager(“default.aspx”, System.Web.UI.WebControls.WebParts.PersonalizationScope.User);
    foreach (System.Web.UI.WebControls.WebParts.WebPart wp in wm.WebParts)
    {
    //process your webpart here
    }
    }
    }
    
    I have done this code for Shared scrop and it works, havent tried with scope User. But you will need some custom code to perform these operation, hopefully that might point you to some direction.
    • Proposed as answer by Chris Geier Friday, April 1, 2011 1:30 PM
    Thursday, March 31, 2011 9:20 PM
  • Hi ,

    I have got the soulution for the problem atlast, we can delete the personalized webparts for particular users programatically by impersonalting the SharePoint user getting the SPSite object in their context and then deleting the personqalized webparts

    :)

    • Marked as answer by Wayne Fan Tuesday, April 5, 2011 8:46 AM
    Sunday, April 3, 2011 12:57 PM
  • Hi

    Can u tell me/explain/provide the solution of implementing popup to add webparts in 2010. i am trying for this solution.

    Now i am able to open the popup with required webparts and failing in adding selected webparts to respected zone.

    Tuesday, October 11, 2011 11:32 AM
  •  

    Hi sanjay let me know in case you need the solution ?

    Friday, December 16, 2011 4:47 AM