![](/img/trans.png)
[英]Is It Possible to Assign Default value to Id from Result of Scalar Function
[英]Is it possible to assign webpart id in onet.xml?
我制作了一個包含三個區域的頁面。 在onet.xml中,我定義了三個Web部件,這些Web部件將在網站創建時添加到頁面中。 是否可以在onet.xml中為每個Web部件分配一個ID,或者是否需要編寫一個功能接收器來連接連接?
我最初的想法是在頁面本身上使用,但是隨后我需要Webpart的ID。
<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>
如果您查看上面的代碼段,則所有的Property都在Properties標記中定義,是否嘗試向其添加ID,我猜它應該可以工作。
<property name="ID" type="string">WebPart1</property>
我找到了兩種解決方案。 一種是將Webpart添加到頁面布局中,而不是在區域中。 那么您可以使用ID將其連接起來。
但是我尋求的解決方案是在我的一個Webpart中創建一個“ InitConnection”函數,該函數在首次運行時將頁面上的所有其他Webpart掛鈎。
我認為可以使用功能裝訂來做同樣的事情,但是我尋求的解決方案很簡單,並且代碼很少。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.