2

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.

2 Answers 2

1

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

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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