Friday, 29 August 2008

Adding Webpart to Custom Site Defenition.

At times we would be finding difficulty to add a custom webpart to your own site definition(Custom), Many a times i had seen this Error popping up becuase of any xml format error in the webpart defenition added.



Error :
[ Web Part Error: The file you imported is not valid. Verify that the file is a Web Part description file (*.webpart or *.dwp) and that it contains well-formed XML. ]



Inorder to get the correct webpart definition look into sharepoint itself
Go to Site settings -> Webparts (under Galleries) -> Click the Edit button/Image next to the webpart you want to add in the site definition, and then click View XML



The XML you get, is the definition that has to be included in the CData part of your page!So, for example you would get: