窗外

在ASPX页面中定义WebPart

在创建自定义的SharePoint页面时,常常需要在其中定义一些WebPart,可是有时候简单的在<WebPartZone>中定义<WebPart>并不起作用。例如下面的代码有可能导致页面错误。

<WebPartPages:WebPartZone
runat=”server” FrameType=”TitleBarOnly” ID=”Left” Title=”loc:Left”>

<ZoneTemplate>

<WebPartPages:ImageWebPart
runat=”server”


Title=”Image Web Part” IsIncluded=”True” Dir=”Default”


ImageLink=”/_layouts/images/homepage.gif”
/>

</ZoneTemplate>

</WebPartPages:WebPartZone>

如果不确定怎样在一个WebPartPage页面中定义一个WebPart,可以先将这个WebPart放入一个SharePoint页面中,并做好相应的设置,然后用SharePoint Designer打开这页面,将WebPartZone中关于这个WebPart的定义拷贝出来,放入自定义的页面中。这个方法通常是可行的,例如上面的ImageWebPart的完整定义是下面这样。

<WebPartPages:WebPartZone
runat=”server” FrameType=”TitleBarOnly” ID=”Left” Title=”loc:Left”>

<ZoneTemplate>

<WebPartPages:ImageWebPart
runat=”server”


VerticalAlignment=”Middle” AllowEdit=”True”


AllowConnect=”True”


ConnectionID=”00000000-0000-0000-0000-000000000000″


Title=”Image Web Part” IsIncluded=”True” Dir=”Default”


BackgroundColor=”transparent”


IsVisible=”True”


AlternativeText=”Microsoft Windows SharePoint Services Logo”


AllowMinimize=”True” ExportControlledProperties=”True”


ZoneID=”Left” ID=”wpImage” HorizontalAlignment=”Left”


ImageLink=”/_layouts/images/homepage.gif”


ExportMode=”All” AllowHide=”True”


SuppressWebPartChrome=”False” DetailLink=””


ChromeType=”None” HelpLink=”” FrameState=”Normal”


MissingAssembly=”Cannot import this Web Part.”


PartImageSmall=”” AllowRemove=”True” HelpMode=”Modeless”


FrameType=”None” AllowZoneChange=”True” PartOrder=”1″


Description=”Use to display pictures and photos.”


PartImageLarge=”” IsIncludedFilter=””


__MarkupType=”vsattributemarkup”


__WebPartId=”{D2B9FF40-8979-4C57-9E5D-9582B5855F18}”


WebPart=”true” Height=”” Width=””></WebPartPages:ImageWebPart>

</ZoneTemplate>

</WebPartPages:WebPartZone>

Tags

Leave a Reply

Your email address will not be published. Required fields are marked *