SharePoint 2010 Schema.xml, Onet.xml and Toolbar Type

I’ve been working pretty heavily the last couple weeks with List Definitions, List Instances and Site Definitions in SharePoint 2010. I’m documenting my process because I was hard pressed to find a solid example of this on the web. I’m mostly concerned with documenting the areas that I found difficult, like the View definition in the Schema.xml and the changes to the Onet.xml Modules element in 2010. What I won’t cover is how to use Visual Studio 2010 to create a new Site Definition project, and add List Definitions to it. Perhaps in another post I’ll try to outline the whole process in more detail.

Let me setup the scenario:

1. I am using Visual Studio 2010 to build a Site Definition that will contain a List Definition and an instance of that List.
2. I want the instance of the List that I create to show up on the default.aspx page of my site automatically when I provision a site using this definition.
3. Finally, I want to display a full toolbar so users can add items directly from the default.aspx page.


<View BaseViewID="50" Type="HTML" MobileView="TRUE" MobileDefaultView="TRUE" ImageUrl="/_layouts/images/generic.png" WebPartZoneID="Main" WebPartOrder="1" Url="Forms/Last Modified.aspx" SetupPath="pagesviewpage.aspx">
        <Toolbar Type="None" />
            <FieldRef Name="Modified" Ascending="False"/>
          <FieldRef Name="DocIcon"></FieldRef>
          <FieldRef Name="LinkFilename"></FieldRef>
          <FieldRef Name="_UIVersionString"></FieldRef>
          <FieldRef Name="Editor"></FieldRef>
          <FieldRef Name="Status"></FieldRef>
          <FieldRef Name="Category"></FieldRef>
        <RowLimit Paged="FALSE">5</RowLimit>
        <Aggregations Value="Off" />

So some things to note in the above.

  1. The Toolbar Type attribute caused a bit of confusion for me because the schema complains that it’s invalid if I set it to a value of None. It works for me anyway. There is a ton of information on the web that describes what these values are allowed to be. I find the following article from MS documents the options well:
    • Standard —The most common type of toolbar, which is used, for example, in the All Items views for most lists, and which corresponds to Full Toolbar in the Web Part tool pane.
    • FreeForm —Used in Default.aspx and Web Part Pages and corresponds to Summary Toolbar in the Web Part tool pane.
    • None —No toolbar is used in the view, corresponding to No Toolbar in the Web Part tool pane.
  2. When adding elements to this xml file, ensure that the Name you specify is the Internal name of that field, not the display name. For things like Version, I was assuming the internal name was Version when it fact it was _UIVersionString or _UIVersion. I haven’t found a neat way to discover these internal names for system or hidden fields, but if I do, I’ll update this post.
  3. Make sure you add a SetupPath tag that points to “pagesviewpage.aspx” so it knows where to go to generate your view.
  4. Finally, be really careful not to set the DefaultView property on more than one View element. I find by doing that, it creates a completely separate list, instead of a view within the current list.


Ok so when we’re ready to add our List Definition to the Onet.xml, a few things slowed me down that I want to point out here. I’m going to show two ways that you would add a list/view to the default.aspx page:

<View List="Project Documents" BaseViewID="1" WebPartZoneID="Right" WebPartOrder="1" />

The above code references a List Definition I have already created called Project Documents, I’m looking for the BaseViewID of 1 (this should be defined in the Schema.xml) and I’m specifying where to position my web part. This technique works really well for me, except, I am not able to set things like the Title of the web part or it’s Chrome.

So I could have done the following:

<View List="Project Documents" Name="Last Modified Project Documents" DisplayName="Last Modified Project Documents" BaseViewID="50" WebPartZoneID="Right" WebPartOrder="2">
                  <webPart xmlns="">
                          <type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart,Microsoft.SharePoint,Version=,Culture=neutral,PublicKeyToken=71e9bce111e9429c" />
                          <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
                              <property name="Title">Last Modified Project Documents</property>
                              <property name="AllowConnect" type="bool">True</property>
                              <property name="AllowClose" type="bool">False</property>

The above now let’s me set things like Title and Chrome.

Lastly, be sure NOT TO DO THIS in SharePoint 2010:

<View List="Project Documents" BaseViewID="50" DisplayName="Last Modified Project Documents" Name="Last Modified Project Documents" RecurrenceRowset="TRUE" WebPartZoneID="Right" WebPartOrder="2">
             <WebPart xmlns="">
                  <Assembly>Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
                  <Title>Last Modified Project Documents</Title>

The above will work fine in SharePoint 2010, but there will be some inconsistency and it won’t behave quite right. If you edit the web part, you’ll notice it’s missing a few of the options that the 2010 ones do.

2 Responses to “SharePoint 2010 Schema.xml, Onet.xml and Toolbar Type”

  1. Brad May 16, 2011 at 9:18 am #

    Hoho, this is the exact info. i need. Thanks dude! :)


  1. Tweets that mention SharePoint 2010 Schema.xml, Onet.xml and Toolbar Type | SharePoint Fun -- - September 1, 2010

    […] This post was mentioned on Twitter by Planet SharePoint, Erik Neumann. Erik Neumann said: #sharepoint SharePoint 2010 Schema.xml, Onet.xml and Toolbar Type: I’ve been working pretty heavily the last coupl… […]

Leave a Reply