WebPart.Connections 属性
获取或设置与连接的 Web 部件一起存储的连接信息。
命名空间: Microsoft.SharePoint.WebPartPages
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
<WebPartStorageAttribute(Storage := Storage.Shared)> _
<BrowsableAttribute(False)> _
Public Property Connections As String
Get
Set
用法
Dim instance As WebPart
Dim value As String
value = instance.Connections
instance.Connections = value
[WebPartStorageAttribute(Storage = Storage.Shared)]
[BrowsableAttribute(false)]
public string Connections { get; set; }
属性值
类型:System.String
string值,该值指定连接信息。默认值是String.Empty未连接的 Web 部件。
备注
该字符串指定Connections属性具有以下格式的每个连接存储与 Web 部件。
ConsumerPartID,ProviderPartID,ConsumerInterfaceName,ProviderInterfaceName,ConsumerIntefaceGroupName,ProviderIntefaceGroupName, XformInfo,CrossPageConnectionID,CrossPageURL,CrossPageInitEventArgs
对每个连接使用由分号 (;) 分隔每个连接存储与 Web 部件重复此格式。存储在最后一个连接后应为没有分号。
下表介绍每个Connections属性字符串的组成部分。
名称 |
说明 |
---|---|
ConsumerPartID |
使用者 Web 部件ConnectionID 。 |
ProviderPartID |
提供程序 Web 部件ConnectionID 。但是,如果用户是在个性化模式下创建此连接,并且提供程序 Web 部件后不具有ConnectionID共享的部件,Web 部件基础结构将使用webPartID属性来改为标识 Web 部件。这是因为无法分配ConnectionID ,并将其保存 Web 部件处于个性化模式时。 |
ConsumerInterfaceName |
使用者 Web 部件 (如通过连接接口的RegisterInterface方法定义) interfaceName 。它将如为一个字符串: myRowConsumer_WPQ_. |
ProviderInterfaceName |
提供程序 Web 部件 (如通过连接接口的RegisterInterface方法定义) interfaceName 。它将如为一个字符串: myRowProvider_WPQ_. |
ConsumerInterfaceGroupName |
使用者 Web 部件interfaceName 。此设置等同于ConsumerInterfaceName参数。 |
ProviderInterfaceGroupName |
提供程序 Web 部件interfaceName 。此设置等同于ProviderInterfaceName参数。 |
XFormInfo |
(可选)它需要在运行时执行其逻辑转换器保存任何消除歧义信息的字符串。下面的定义和示例所附带的 Web 部件基础结构的转换器。
|
CrossPageConnectionID |
(可选)对于跨页连接,这是连接的 Web 部件连接到其他页面上的唯一标识符。crosspageconnectionid参数Guid并且必须唯一两页上。创作工具应生成此 id。 |
CrossPageURL |
(可选)对于跨页连接,这是页面的 Web 部件连接到的 URL。 |
CrossPageInitEventArgs |
(可选)对于跨页连接,这是界面的InitEventArgs结构的其他 Web 部件正在连接到格式设置为一个 XML 片段页上。以下是格式为CrossPageInitEventArgs参数IFilterConsumerInitEventArgs结构的示例。 <FilterConsumerInitEventArgs>><Field FieldName="First Name" FieldDisplayName="First Name"/><Field FieldName="Surname" FieldDisplayName="Sur Name"/><Field FieldName="Phone" FieldDisplayName="Phone Number"/><Field FieldName="Company" FieldDisplayName="Company"/></FilterConsumerInitEventArgs> 以下是格式为CrossPageInitEventArgs参数IParametersInConsumerInitEventArgs结构的示例。 <ParametersInConsumerInitEventArgs><Parameter ParameterName="LName" ParameterDisplayName="Last Name" Required="True" Description="Last Name of an employee."><Parameter ParameterName="FName" ParameterDisplayName="First Name" Required="True" Description="First Name of an employee."><Parameter ParameterName="Co" ParameterDisplayName="Company" Required="False" Description="Company the employee previously worked for."><Parameter ParameterName="Phone" ParameterDisplayName="Business Phone" Required="False" Description="Business Phone Number of an employee."></ParametersInConsumerInitEventArgs> |
逗号用于分隔的连接的各个参数。使用分号分隔整个连接。空白不允许之前或之后分隔符。如果任何参数中使用了逗号、 分号还是百分号,Web 部件基础结构将编码的分隔符下, 表中所示。
分隔符 |
编码 |
---|---|
, |
%2 C |
; |
%3B |
% |
25% |
Connections属性的值将存储在只有一个端 (Web 部件) 的连接,除非它是一个跨页连接。跨页连接的连接的连接两侧一起存储。默认情况下,Web 部件基础结构存储与使用者 Web 部件Connections属性的值,尽管基础结构将支持静态 Web 部件 ( WebPartZone控件之外的 Web 部件) 和跨页连接的提供程序侧存储连接。
此属性不能由单个用户进行个性化设置。WebPartStorageAttribute其值为Storage.Shared,用于指定属性存储的所有用户的相同值。只有具有写网页右侧的用户可以设置该属性。可以只能以编程方式设置它。
示例
以下是Connections属性设置为之间ICellProvider和ICellConsumer Web 部件相同的 Web 部件页上的直接连接的示例。
f690a578-6d1b-4d04-b081-011a93fa23bf,332f8676-875b-44eb-a537-8f946edb7e5f,MyCellConsumer_WPQ_,MyCellProvider_WPQ_,MyCellConsumer_WPQ_,MyCellProvider_WPQ_
下面是IFilterConsumer Web 部件和IRowProvider使用转换器的 Web 部件之间的跨页连接的两侧Connections属性设置的示例。
(源 ASPX) 中的源页上的 Web 部件的Connection属性设置如下所示:
a93e4d5a-835b-4a80-80c0-a0e23149ed03,69c42cf9-e98b-4f6e-954a-42c7b46ba32e,MyFilterConsumerInterface_WPQ_,RowProviderInterface,MyFilterConsumerInterface_WPQ_,RowProviderInterface,Surname=Last%20Name,0e194b89-eaf0-4fcb-93f9-fe6c0a7a88d1,target.aspx,<FilterConsumerInitEventArgs>><Field FieldName="First Name" /><Field FieldName="Surname" /><Field FieldName="Phone" /><Field FieldName="Company" /></FilterConsumerInitEventArgs>
目标页 (目标 ASPX) 上的Connection属性设置为 Web 部件如下所示:
a93e4d5a-835b-4a80-80c0-a0e23149ed03,69c42cf9-e98b-4f6e-954a-42c7b46ba32e,MyFilterConsumerInterface_WPQ_,RowProviderInterface,MyFilterConsumerInterface_WPQ_,RowProviderInterface,,0e194b89-eaf0-4fcb-93f9-fe6c0a7a88d1,source.aspx,