2009-08-28 21 views
0

我用三個區域製作了一個頁面。在onet.xml中,我定義了三個webparts,它們將在網站創建時添加到頁面中。是否可以爲onet.xml中的每個webpart分配一個id,還是需要編寫一個連接連接的功能接收器?是否可以在onet.xml中分配webpart id?

我最初的想法是在頁面本身上使用,但後來我需要Web部件的ID。

回答

0

我發現了兩種解決方案。一種是將webparts添加到頁面佈局,但不能添加到區域中。那麼你可以使用id來掛鉤它們。

但我選擇的解決方案是在我的一個webparts中創建一個「InitConnection」函數,該函數在第一次運行時將頁面上的所有其他webparts連接起來。

我認爲可以對功能裝訂進行同樣的操作,但我選擇的解決方案非常簡單,代碼也很少。

0
<AllUsersWebPart WebPartZoneID="TopColumnZone" WebPartOrder="1"><![CDATA[ 
      <webParts> 
       <webPart xmlns="http://schemas.microsoft.com/WebPart/v3"> 
        <metaData> 
         <type name="Microsoft.SharePoint.Publishing.WebControls.TableOfContentsWebPart,Microsoft.SharePoint.Publishing,Version=12.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c" /> 
         <importErrorMessage>$Resources:cmscore,WebPartImportError;</importErrorMessage> 
        </metaData> 
        <data> 
         <properties> 
          <property name="Title" type="string">$Resources:cmscore,PublishingLayouts_TOCWebPart_Title;</property> 
          <property name="Description" type="string">$Resources:cmscore,PublishingLayouts_TOCWebPart_Description;</property> 
          <property name="ShowPages" type="bool">True</property> 
          <property name="IncludeContentFromStartingLocation" type="bool">False</property> 
          <property name="ChromeType" type="chrometype">None</property> 
          <property name="ChromeState" type="chromestate">Normal</property> 
          <property name="HelpUrl" type="string">/_layouts/help.aspx</property> 
         </properties> 
        </data> 
       </webPart> 
      </webParts>]]> 
     </AllUsersWebPart> 

如果你看一下上面的代碼中所有財產都在屬性標籤定義,你有沒有嘗試過的ID添加到它,我的猜測是它應該工作。

<property name="ID" type="string">WebPart1</property> 
+0

它用站點創建中的g_ {random guid}來替換我放在onet.xml中的ID。我想我必須採用編程方式,或者只需手動將其掛接在GUI上。 – 2009-08-31 08:54:40

相關問題