Search code examples
c#.netsharepointwindows-sharepoint-services

Is it possible to assign webpart id in onet.xml?


I've made a page with with three zones. In onet.xml I have defined three webparts which will be added to the page upon site creation. Is it possible to assign an id to each webpart in onet.xml, or do I need to write a feature receiver which hooks up the connections?

My initial thought was to use on the page itself, but then I need the id's of the webparts.


Solution

  • I've found two solutions. One is to add the webparts to a page layout, but not in zones. then you can use the id's to hook them up.

    But the solution I went for was to create a "InitConnection" function in one of my webparts which hooks up all the other webparts on the page the first time it's run.

    I think it would be possible to do the same with feature stapling, but the solution I went for was easy and little code.