Add a webpart to page using Onet/Feature


Custom home page is quite common requirement for any development project. This post helps you if you need to add out of box web part to page. This post contains good details how to deploy custom page.

The AllUsersWebPart tag allow us to insert a custom/Out of box web part and It also contains few attributes which are used to place web part. Two important attributes are WebPartOrder and WebPartZone attributes. The content of the tag is the dwp (or webpart) of any web part. The tag cloud dwp code example is given below:

<AllUsersWebPart WebPartZoneID="Right" WebPartOrder="3">           <![CDATA[<WebPart xmlns="">                       <Title>Tag Cloud</Title>                       <Description>Displays the most popular subjects being tagged inside your organization.</Description>                       <FrameType>TitleBarOnly</FrameType>                       <ChromeType>None</ChromeType>                       <AllowRemove>true</AllowRemove>                       <AllowMinimize>true</AllowMinimize>                       <Assembly>Microsoft.SharePoint.Portal, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>                      <TypeName>Microsoft.SharePoint.Portal.WebControls.TagCloudWebPart</TypeName>                     </WebPart>         ]]>         </AllUsersWebPart> 

For .webpart, following

<AllUsersWebPart WebPartZoneID="MiddleLeftZone" WebPartOrder="1">     <![CDATA[                                                     <webParts>         <webPart xmlns="">           <metaData>             <type name="MyClass, MyAssembly, Version=, Culture=neutral, PublicKeyToken=f3b9d1137704f880" />             <importErrorMessage>No se puede importar este elemento Web.</importErrorMessage>           </metaData>           <data>             <properties>               <property name="AllowClose" type="bool">False</property>               <property name="AllowMinimize" type="bool">False</property>               <property name="AllowConnect" type="bool">True</property>               <property name="ChromeType" type="chrometype">None</property>               <property name="Hidden" type="bool">False</property>               <property name="AllowEdit" type="bool">False</property>               <property name="AllowZoneChange" type="bool">False</property>               <property name="MissingAssembly" type="string">No se puede importar este elemento Web.</property>               <property name="ChromeState" type="chromestate">Normal</property>             </properties>           </data>         </webPart>       </webParts>     ]]>   </AllUsersWebPart> 

AllUserWebPart tag can be used in onet.xml under “File” tag. If we are adding the custom page using the feature then also the same way we can define this tag value to the File tag.

Thanks for your time :)…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s