Thursday, February 21, 2013

Adding note board web part programmatically in SharePoint 2010


If you want to add note board web part by object model, here is a simple way to add it. I have one web part page.


To demonstrate I have added this code in button click.

       private void button3_Click(object sender, EventArgs e)
        {
            using (SPSite site =
new SPSite("{Site URL}"))
            {
                using (SPWeb web = site.OpenWeb())
                {

                    SPLimitedWebPartManager webPartManager = web.GetLimitedWebPartManager("SitePages/NoteBoard.aspx", System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);

                    SocialCommentWebPart noteboardwp =
                    new SocialCommentWebPart();

                    webPartManager.AddWebPart(noteboardwp ,
                     "MiddleZone", 0);
                }
            }
        }

and here is what you get out of it


No comments:




Share your SharePoint Experiences with us...
As good as the SharePointKings is, we want to make it even better. One of our most valuable sources of input for our Blog Posts comes from ever enthusiastic Visitors/Readers. We welcome every Visitor/Reader to contribute their experiences with SharePoint. It may be in the form of a code stub, snippet, any tips and trick or any crazy thing you have tried with SharePoint.
Send your Articles to sharepointkings@gmail.com with your Profile Summary. We will Post them. The idea is to act as a bridge between you Readers!!!

If anyone would like to have their advertisement posted on this blog, please send us the requirement details to sharepointkings@gmail.com