Coding for funny


When I create a new sharepoint template for my project use, I want to set the value for webpart’s properties as soon as the site created using this template. Adding a list by default is easy after my reading of the great article from . I have developed a webpart for list displaying, and I know how to add this webpart in the rootweb by default, but I don’t know how to set value for the webpart’s properties by default. When I open a Onet.xml from one built-in template I got a example as follows:

 1 <AllUsersWebPart WebPartZoneID="Right" WebPartOrder="1">
 2                    <![CDATA[
 3                    <WebPart xmlns="" xmlns:iwp="">
 4                         <Assembly>Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
 5                         <TypeName>Microsoft.SharePoint.WebPartPages.ImageWebPart</TypeName>
 6                         <FrameType>None</FrameType>
 7                         <Title>网站图像</Title>
 8                         <iwp:ImageLink>/_layouts/images/homepage.gif</iwp:ImageLink>
 9                    </WebPart>
10                    ]]>
11                 </AllUsersWebPart>

I believe line 8 is the key of my problem. And now the problem is how to set the iwp prefix. After my reflector of Microsoft.SharePoint.WebPartPages.ImageWebPart, I got some interesting code fragment below:

1 [Guid("20743A06-C4E6-4984-A8A0-918C34353148"), XmlRoot(Namespace="")]
2 public sealed class ImageWebPart : WebPart, IDesignTimeHtmlProvider, ICellConsumer
3 {
4 //
5 }

Compare xmlns:iwp="" to  XmlRoot(Namespace=""), I know the answer. my webpart xmlroot is "Microsoft.MCS.HPITeam.Portal.WebParts", so I registered my webpart as following:

<AllUsersWebPart WebPartZoneID="Middle" WebPartOrder="2">
                   <WebPart xmlns="" xmlns:dtl="Microsoft.MCS.HPITeam.Portal.WebParts">
                        <Assembly>Microsoft.MCS.HPITeam.Portal.WebParts, Version=, Culture=neutral, PublicKeyToken=541eeb7342aeb9f8</Assembly>