How to add a custom WebPart to person.aspx for all users

Hi,

we are using MySites and i have developed a WebPart which should be placed on the person.aspx page.

I want to modify this page by the feature event receiver and add the custom webpart to the person.aspx page for all users.

How can i achieve

August 13th, 2014 7:46am

Hi,

According to your post, my understanding is that you wanted to add web part to the person.aspx page.

We can use the following code snippets to add the web part to the person.aspx page with feature event receiver.

public override void FeatureActivated(SPFeatureReceiverProperties properties)

        {

            using (SPSite rootSite = properties.Feature.Parent as SPSite)

           {

               using (SPWeb web=rootSite.OpenWeb())

               {

                   SPFile file = web.GetFile(web.Url + "person.aspx");

                   using (SPLimitedWebPartManager webpartsMng = file.GetLimitedWebPartManager(PersonalizationScope.User))

                   {

                       ContentEditorWebPart webPart = new ContentEditorWebPart();

                       webPart.Title = "Test Web Part";

                       webpartsMng.AddWebPart(webPart, "Right", 0);

                       webpartsMng.Web.Dispose();

                   } 

               }

              

           }

        }

https://www.nothingbutsharepoint.com/sites/devwiki/SP2007Dev/Pages/How%20to%20create%20Web%20Part%20instances%20on%20pages%20using%20Features%20-%20FeatureReceiver%20-%20SPLimitedWebPartManager.aspx

Thanks & Regards,

Jason
Free Windows Admin Tool Kit Click here and download it now
August 14th, 2014 5:27am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics