1
votes

I created a custom sitedefinition. In my sitedefition i want to activate a custom feature (i add the guid into my onet.xml).

My custom feature for adding the webpart to the page is creating an error. The error is default.aspx is not found. I thought a page in a sitedefition is created first. After that feature will be activate. Why i receive an error?

SPLimitedWebPartManager collWebParts =  web.GetLimitedWebPartManager("default.aspx", System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);

collWebParts.AddWebPart(CustomWebPart, "MainLeft", 1);
collWebParts.SaveChanges(CustomWebPart);
collWebParts.Web.Dispose();
1
How are you creating default.aspx ? Is it again through feature in onet.xml ? Check the ordering of feature GUID specified - Madhur Ahuja
The default.aspx is standard in a sitedefinition. - Active_t

1 Answers

2
votes

You'd better add you webparts in modules in onet.xml. Just add the tag and use the tag to provision your particular webparts.

A simple sample:

<Modules>
    <Module Name="DefaultBlank" Url="" Path="">
      <File Url="default.aspx" Path="default.aspx">
        <AllUsersWebPart WebPartOrder="0" WebPartZoneID="Right" ID="g_bdef0b56_c2f4_4c5a_bc39_2908a0f61410">
        <![CDATA[<webParts>
        <webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
          <metaData>
            <type name="***.LatestDiscussionsWebPart.LatestDiscussionsWebPart, ***, Version=1.0.0.0, Culture=neutral, PublicKeyToken=20cca094e7d0240a" />
            <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
          </metaData>
          <data>
            <properties>
              <property name="AllowZoneChange" type="bool">True</property>
              <property name="ExportMode" type="exportmode">All</property>
              <property name="HelpUrl" type="string" />
              <property name="Hidden" type="bool">False</property>
              <property name="TitleUrl" type="string" />
              <property name="Description" type="string">Latest Discussions WebPart</property>
              <property name="AllowHide" type="bool">True</property>
              <property name="AllowMinimize" type="bool">True</property>
              <property name="Title" type="string">Latest Discussions </property>
              <property name="ChromeType" type="chrometype">Default</property>
              <property name="AllowConnect" type="bool">True</property>
              <property name="Width" type="unit" />
              <property name="Height" type="unit" />
              <property name="HelpMode" type="helpmode">Navigate</property>
              <property name="CatalogIconImageUrl" type="string" />
              <property name="AllowEdit" type="bool">True</property>
              <property name="TitleIconImageUrl" type="string" />
              <property name="Direction" type="direction">NotSet</property>
              <property name="AllowClose" type="bool">True</property>
              <property name="ChromeState" type="chromestate">Normal</property>
            </properties>
          </data>
        </webPart>
      </webParts>]]>
        </AllUsersWebPart>
      </File>
</Module>

Good luck.