ConnectionsZone.ConnectVerb 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取一个对 WebPartVerb 对象的引用,该对象使两个 WebPart 控件可以建立连接。
public:
virtual property System::Web::UI::WebControls::WebParts::WebPartVerb ^ ConnectVerb { System::Web::UI::WebControls::WebParts::WebPartVerb ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public virtual System.Web.UI.WebControls.WebParts.WebPartVerb ConnectVerb { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.ConnectVerb : System.Web.UI.WebControls.WebParts.WebPartVerb
Public Overridable ReadOnly Property ConnectVerb As WebPartVerb
属性值
一个 WebPartVerb,使两个控件可以建立连接。
- 属性
示例
下面的代码示例演示如何将 ConnectVerb 属性与控件一 ConnectionsZone 起使用。 该示例仅包含演示如何使用该属性的网页的代码;有关运行该示例所需的其他两个代码文件,请参阅类概述的示例 ConnectionsZone 部分。 代码示例包含四个部分:
允许用户在网页上切换显示模式的用户控件。 从 ConnectionsZone 类概述中获取此代码。
一个源文件,其中包含邮政编码接口的代码,以及充当连接提供程序和使用者的两 WebPart 个控件。 从 ConnectionsZone 类概述中获取此代码。
承载所有控件的网页,声明一个
<asp:connectionszone>
元素,并演示如何以声明方式和编程方式使用属性。说明示例在浏览器中的工作原理。
网页声明元素 <asp:connectionszone>
,并在元素标记中声明元素 <connectverb>
,并使用属性设置一些属性。 此外,在 Page_PreRender
方法中,代码在控件的连接谓词 ConnectionsZone 上设置一些属性。
<%@ Page Language="C#" %>
<%@ register tagprefix="uc1"
tagname="DisplayModeMenuCS"
src="~/displaymodemenucs.ascx" %>
<%@ Register TagPrefix="aspSample"
Namespace="Samples.AspNet.CS.Controls" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_PreRender(object sender, EventArgs e)
{
// Set properties on verbs.
connectionsZone1.CancelVerb.Description =
"Terminates the connection process";
connectionsZone1.CloseVerb.Description =
"Closes the connections UI";
connectionsZone1.ConfigureVerb.Description =
"Configure the transformer for the connection";
connectionsZone1.ConnectVerb.Description =
"Connect two WebPart controls";
connectionsZone1.DisconnectVerb.Description =
"End the connection between two controls";
// Set properties for UI text strings.
connectionsZone1.ConfigureConnectionTitle =
"Configure";
connectionsZone1.ConnectToConsumerInstructionText =
"Choose a consumer connection point";
connectionsZone1.ConnectToConsumerText =
"Select a consumer for the provider to connect with";
connectionsZone1.ConnectToConsumerTitle =
"Send data to this consumer";
connectionsZone1.ConnectToProviderInstructionText =
"Choose a provider connection point";
connectionsZone1.ConnectToProviderText =
"Select a provider for the consumer to connect with";
connectionsZone1.ConnectToProviderTitle =
"Get data from this provider";
connectionsZone1.ConsumersInstructionText =
"WebPart controls that receive data from providers";
connectionsZone1.ConsumersTitle = "Consumer Controls";
connectionsZone1.GetFromText = "Receive from";
connectionsZone1.GetText = "Retrieve";
connectionsZone1.HeaderText =
"Create and Manage Connections";
connectionsZone1.InstructionText =
"Manage connections for the selected WebPart control";
connectionsZone1.InstructionTitle =
"Manage connections for consumers or providers";
connectionsZone1.NoExistingConnectionInstructionText =
"No connections exist. Click the above link to create "
+ "a connection.";
connectionsZone1.NoExistingConnectionTitle =
"No current connections";
connectionsZone1.ProvidersInstructionText =
"WebPart controls that send data to consumers";
connectionsZone1.ProvidersTitle = "Provider controls";
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Connection Zone Sample</title>
</head>
<body>
<form id="form1" runat="server">
<asp:webpartmanager runat="server" id="mgr">
<staticconnections>
<asp:webpartconnection id="connection1"
consumerconnectionpointid="ZipCodeConsumer"
consumerid="zipConsumer"
providerconnectionpointid="ZipCodeProvider"
providerid="zipProvider" />
</staticconnections>
</asp:webpartmanager>
<uc1:displaymodemenucs id="menu1" runat="server" />
<div>
<asp:webpartzone id="WebPartZone1" runat="server">
<zonetemplate>
<aspsample:zipcodewebpart id="zipProvider" runat="server"
Title="Zip Code Provider" />
<aspsample:weatherwebpart id="zipConsumer" runat="server"
Title="Zip Code Consumer" />
</zonetemplate>
</asp:webpartzone>
<asp:connectionszone id="connectionsZone1" runat="server" >
<cancelverb text="Terminate" />
<closeverb text="Close Zone" />
<configureverb text="Configure" />
<connectverb text="Connect Controls" />
<disconnectverb text="End Connection" />
</asp:connectionszone>
</div>
</form>
</body>
</html>
<%@ Page Language="VB" %>
<%@ register tagprefix="uc1"
tagname="DisplayModeMenuVB"
src="~/displaymodemenuvb.ascx" %>
<%@ Register TagPrefix="aspSample"
Namespace="Samples.AspNet.VB.Controls" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_PreRender(ByVal sender As Object, _
ByVal e As System.EventArgs)
' Set properties for verbs.
connectionsZone1.CancelVerb.Description = _
"Terminates the connection process"
connectionsZone1.CloseVerb.Description = _
"Closes the connections UI"
connectionsZone1.ConfigureVerb.Description = _
"Configure the transformer for the connection"
connectionsZone1.ConnectVerb.Description = _
"Connect two WebPart controls"
connectionsZone1.DisconnectVerb.Description = _
"End the connection between two controls"
' Set properties for UI text strings.
connectionsZone1.ConfigureConnectionTitle = _
"Configure a new connection"
connectionsZone1.ConnectToConsumerInstructionText = _
"Choose a consumer connection point"
connectionsZone1.ConnectToConsumerText = _
"Select a consumer for the provider to connect with"
connectionsZone1.ConnectToConsumerTitle = _
"Send data to this consumer"
connectionsZone1.ConnectToProviderInstructionText = _
"Choose a provider connection point"
connectionsZone1.ConnectToProviderText = _
"Select a provider for the consumer to connect with"
connectionsZone1.ConnectToProviderTitle = _
"Get data from this provider"
connectionsZone1.ConsumersInstructionText = _
"WebPart controls that receive data from providers"
connectionsZone1.ConsumersTitle = "Consumer Controls"
connectionsZone1.GetFromText = "Receive from"
connectionsZone1.GetText = "Retrieve"
connectionsZone1.HeaderText = _
"Create and Manage Connections"
connectionsZone1.InstructionText = _
"Manage connections for the selected WebPart control"
connectionsZone1.InstructionTitle = _
"Manage connections for consumers or providers"
connectionsZone1.NoExistingConnectionInstructionText = _
"No connections exist. Click the above link to create " _
& "a connection."
connectionsZone1.NoExistingConnectionTitle = _
"No current connections"
connectionsZone1.ProvidersInstructionText = _
"WebPart controls that send data to consumers"
connectionsZone1.ProvidersTitle = "Provider controls"
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Connection Zone Sample</title>
</head>
<body>
<form id="form1" runat="server">
<asp:webpartmanager runat="server" id="mgr">
<staticconnections>
<asp:webpartconnection id="connection1"
consumerconnectionpointid="ZipCodeConsumer"
consumerid="zipConsumer"
providerconnectionpointid="ZipCodeProvider"
providerid="zipProvider" />
</staticconnections>
</asp:webpartmanager>
<uc1:displaymodemenuvb id="menu1" runat="server" />
<div>
<asp:webpartzone id="WebPartZone1" runat="server">
<zonetemplate>
<aspsample:zipcodewebpart id="zipProvider" runat="server"
Title="Zip Code Provider" />
<aspsample:weatherwebpart id="zipConsumer" runat="server"
Title="Zip Code Consumer" />
</zonetemplate>
</asp:webpartzone>
<asp:connectionszone id="connectionsZone1" runat="server" >
<cancelverb text="Terminate" />
<closeverb text="Close Zone" />
<configureverb text="Configure" />
<connectverb text="Connect Controls" />
<disconnectverb text="End Connection" />
</asp:connectionszone>
</div>
</form>
</body>
</html>
在浏览器中加载页面。 使用 显示模式 控件切换到连接模式。 单击 邮政编码提供程序 控件上的谓词菜单箭头,然后单击连接谓词。 单击“ 结束连接 ”按钮可断开由于页面上声明性连接而已连接的控件的连接。 单击 提供程序的“选择使用者”以使用超链接进行连接 ,并注意到设置各种属性的效果。 如果将鼠标指针放在 “连接控件”按钮上,自定义说明文本将显示在工具提示中。
注解
与控件一起使用 ConnectionsZone 的连接谓词是一个区域级谓词,该谓词显示在连接用户界面 (UI) 作为用户完成两个控件之间的连接的一部分。 在 UI 的一部分,用户可以选择连接点(如果两个控件能够连接),则会在 UI 底部附近启用连接谓词。 用户选择连接点后,可以单击连接谓词来创建连接。
备注
本主题中讨论的区域级连接谓词实际上在控件之间建立连接,与控件的 WebPart 谓词菜单上显示的谓词不同。 当用户切换网页以连接显示模式时,如果控件可以形成连接, WebPart 则连接谓词会显示在其谓词菜单上。 此 WebPart 连接谓词只是打开由控件创建 ConnectionsZone 的连接 UI。 相比之下, ConnectVerb 本主题中讨论的谓词实际上在区域级别操作,实际上会创建一个连接。
使用属性 ConnectVerb 获取对 UI 中相应 WebPartVerb 对象的引用。 尽管属性本身是只读的,但在对谓词有引用后,可以根据需要更改其属性值。
可以通过声明元素的开始标记和结束标记之间声明 <connectverb>
连接谓词的 <asp:connectionszone>
属性值。 还可以通过在窗体Property-Subproperty
中添加属性,在元素的<asp:connectionszone>
开始标记中以声明方式设置谓词的属性,其中Subproperty
对象的属性WebPartVerb (例如 ConnectVerb-Text
) 。 还可以以编程方式在窗体 Property.Subproperty
(设置属性,例如 ConnectVerb.Text
,) 。