开发者

Sharepoint webpart in aspx page -markup

开发者 https://www.devze.com 2023-02-13 14:18 出处:网络
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.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消