Help with WebPartCollection
- From: "Rickard" <Rickard@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 25 Jul 2005 13:52:01 -0700
Hi,
I have a problem checking if a webpart exist in the collection and add it if
it does not exist.
My problem is that a new webpart is added everytime the code runs.. Clearly
not what I want to happen.
Here is my code below:
//Code Snippet
SPWeb web = site.OpenWeb (url);
SPFile file = web.GetFile("default.aspx");
SPWebPartCollection parts = file.GetWebPartCollection (Storage.Shared);
WSSCFooter.WebPartFooter footer = new WSSCFooter.WebPartFooter();
footer.ZoneID = "BottomZone";
footer.Title = "Footer";
if (!parts.Contains(footer))
{
parts.Add(footer);
Console.WriteLine("WsscFooter added to " + web.Url);
}
//End Code Snippet
Any idea why this is not working?
Any help appreciated!
Regards,
Rickard
.
- Follow-Ups:
- RE: Help with WebPartCollection
- From: simon
- RE: Help with WebPartCollection
- Prev by Date: RE: Form Management in Sharepoints
- Next by Date: Authentication/Impersonation
- Previous by thread: Cross-site Group
- Next by thread: RE: Help with WebPartCollection
- Index(es):
Relevant Pages
|
|