Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

What's the best method for adding an XsltListViewWebPart to a site definition's default.aspx?

I've tried to add one to the definition's default.aspx declaratively by copying the XML from an existing page, but there are a number of references to view and list guids which I won't have until the site is provisioned. The alternative was to programmatically add to the default.aspx via a site provisioned or feature activated event handler, but it's impossible to get a reference to the default.aspx until the site has been created.

share|improve this question
add comment

2 Answers

There is a WebProvisioned event receiver you can how hook into in 2010.

This executes once the pages are loaded, have a looksie at this:

http://stefan-stanev-sharepoint-blog.blogspot.com/2010/09/webprovisioned-event-receiver-practical.html

share|improve this answer
add comment

Is the list the WebPart needs to look at is also provisioned as part of the Site Definition?

If so, rather than using the AllUsersWebPart element in the definition, you can use the View element.

Some of the out of the box site definitions do this (Like Blog) so you can look at them for a starting point.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.