开发者

Adding Web Part with Stapling Feature

I have a problem adding web part to a blog default.aspx with stapling Feature. this is my code:

try
{
SPWeb web = (SPWeb)properties.Feature.Parent;
//SPFile thePage = web.RootFolder.Files["default.aspx"];
SPLimitedWebPartManager wpm = web.GetLimitedWebPartManager("default.aspx",PersonalizationScope.Shared);

.......

but every time I try to get default.aspx it says that file does not exist. Anyone can help me on this, because all the articles about开发者_开发技巧 adding web parts with features while site is creating (Stapling Feature) point on this kind of solution. Is there anything special?


Are you activating your feature in a publishing web? It may not have a default.aspx in the root then, but in /Pages/Default.aspx


I think that when you the staple a feature the feature is activated before all the content is added. The feaure has to have that page as bart of the feature, then you should be able to add the web part.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜