Posts

Showing posts with the label Add Webpart Programatically

Add Web Part Programatically on Home / Default Page

Hi, Create a SharePoint 2010 Solution in Visual Studio. Add Feature & its scope. Add Feature Receiver Class & the add below mentioned code :         public override void FeatureActivated(SPFeatureReceiverProperties properties)         {             // Get a reference to a web and a list             SPWeb web = properties.Feature.Parent as SPWeb;             string pageURL=web.RootFolder.WelcomePage;             if(pageURL=="")                 pageURL="default.aspx";             SPLimitedWebPartManager mgr = web.GetLimitedWebPartManager(pageURL  , System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);                          // Add the web part   ...