Sharepoint webpart in aspx page -markup
I am trying to add a webpart to aspx page webpart code is pasted below. I am able to see the content in the page, but it is not recognized as webpart.
using (SPLimitedWebPartManager wpm = file.GetLimitedWebPartManager(System.Web.UI.WebControls.WebParts.Person开发者_如何转开发alizationScope.User))
{
foreach (WebPart wp in wpm.WebParts)
}
i am getting wpm.weparts.count=0 always until i customize the page and make it as un-ghosted.
may i know what i am doing it wrong here?
You should use System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared instead of System.Web.UI.WebControls.WebParts.PersonalizationScope.User.
Shared: gives you all the webparts which is on the pages for all users
User: only gives you the webparts where the current user has made any personalization
精彩评论