共用方式為


ConnectionsZone Web 伺服器控制項宣告式語法

更新:2007 年 11 月

提供使用者介面 (UI),可讓使用者形成位於 WebPartZoneBase 區域中之 WebPart 控制項和其他伺服器控制項之間的連接。

 <asp:ConnectionsZone     AccessKey="string"     BackColor="color name|#dddddd"     BackImageUrl="uri"     BorderColor="color name|#dddddd"     BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|Ridge|                  Inset|Outset"     BorderWidth="size"     CancelVerb-Checked="True|False"     CancelVerb-Description="string"     CancelVerb-Enabled="True|False"     CancelVerb-ImageUrl="uri"     CancelVerb-Text="string"     CancelVerb-Visible="True|False"     CloseVerb-Checked="True|False"     CloseVerb-Description="string"     CloseVerb-Enabled="True|False"     CloseVerb-ImageUrl="uri"     CloseVerb-Text="string"     CloseVerb-Visible="True|False"     ConfigureConnectionTitle="string"     ConfigureVerb-Checked="True|False"     ConfigureVerb-Description="string"     ConfigureVerb-Enabled="True|False"     ConfigureVerb-ImageUrl="uri"     ConfigureVerb-Text="string"     ConfigureVerb-Visible="True|False"     ConnectToConsumerInstructionText="string"     ConnectToConsumerText="string"     ConnectToConsumerTitle="string"     ConnectToProviderInstructionText="string"     ConnectToProviderText="string"     ConnectToProviderTitle="string"     ConnectVerb-Checked="True|False"     ConnectVerb-Description="string"     ConnectVerb-Enabled="True|False"     ConnectVerb-ImageUrl="uri"     ConnectVerb-Text="string"     ConnectVerb-Visible="True|False"     ConsumersInstructionText="string"     ConsumersTitle="string"     CssClass="string"     DisconnectVerb-Checked="True|False"     DisconnectVerb-Description="string"     DisconnectVerb-Enabled="True|False"     DisconnectVerb-ImageUrl="uri"     DisconnectVerb-Text="string"     DisconnectVerb-Visible="True|False"     EmptyZoneText="string"     Enabled="True|False"     EnableTheming="True|False"     EnableViewState="True|False"     ExistingConnectionErrorMessage="string"     Font-Bold="True|False"     Font-Italic="True|False"     Font-Names="string"     Font-Overline="True|False"     Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium|                Large|X-Large|XX-Large"         Font-Strikeout="True|False"     Font-Underline="True|False"     ForeColor="color name|#dddddd"     GetFromText="string"     GetText="string"     HeaderCloseVerb-Checked="True|False"     HeaderCloseVerb-Description="string"     HeaderCloseVerb-Enabled="True|False"     HeaderCloseVerb-ImageUrl="uri"     HeaderCloseVerb-Text="string"     HeaderCloseVerb-Visible="True|False"     HeaderText="string"     Height="size"     ID="string"     InstructionText="string"     InstructionTitle="string"     NewConnectionErrorMessage="string"     NoExistingConnectionInstructionText="string"     NoExistingConnectionTitle="string"     OnDataBinding="DataBinding event handler"     OnDisposed="Disposed event handler"     OnInit="Init event handler"     OnLoad="Load event handler"     OnPreRender="PreRender event handler"     OnUnload="Unload event handler"     Padding="integer"     PartChromeType="Default|TitleAndBorder|None|TitleOnly|BorderOnly"     ProvidersInstructionText="string"     ProvidersTitle="string"     runat="server"     SendText="string"     SendToText="string"     SkinID="string"     Style="string"     TabIndex="integer"     ToolTip="string"     VerbButtonType="Button|Image|Link"     Width="size" >         <EmptyZoneTextStyle />         <ErrorStyle />         <FooterStyle             BackColor="color name|#dddddd"             BorderColor="color name|#dddddd"             BorderStyle="NotSet|None|Dotted|Dashed|Solid|                          Double|Groove|Ridge|Inset|Outset"             BorderWidth="size"             CssClass="string"             Font-Bold="True|False"             Font-Italic="True|False"             Font-Names="string"             Font-Overline="True|False"             Font-Size="string|Smaller|Larger|XX-Small|                        X-Small|Small|Medium|Large|X-Large|XX-Large"             Font-Strikeout="True|False"             Font-Underline="True|False"             ForeColor="color name|#dddddd"             Height="size"             HorizontalAlign="NotSet|Left|Center|Right|Justify"             OnDisposed="Disposed event handler"             VerticalAlign="NotSet|Top|Middle|Bottom"             Width="size"             Wrap="True|False"         />         <HeaderStyle             BackColor="color name|#dddddd"             BorderColor="color name|#dddddd"             BorderStyle="NotSet|None|Dotted|Dashed|Solid|                          Double|Groove|Ridge|Inset|Outset"             BorderWidth="size"             CssClass="string"             Font-Bold="True|False"             Font-Italic="True|False"             Font-Names="string"             Font-Overline="True|False"             Font-Size="string|Smaller|Larger|XX-Small|                        X-Small|Small|Medium|Large|X-Large|XX-Large"             Font-Strikeout="True|False"             Font-Underline="True|False"             ForeColor="color name|#dddddd"             Height="size"             HorizontalAlign="NotSet|Left|Center|Right|Justify"             OnDisposed="Disposed event handler"             VerticalAlign="NotSet|Top|Middle|Bottom"             Width="size"             Wrap="True|False"         />         <PartChromeStyle />         <PartStyle             BackColor="color name|#dddddd"             BackImageUrl="uri"             BorderColor="color name|#dddddd"             BorderStyle="NotSet|None|Dotted|Dashed|Solid|                          Double|Groove|Ridge|Inset|Outset"             BorderWidth="size"             CellPadding="integer"             CellSpacing="integer"             CssClass="string"             Font-Bold="True|False"             Font-Italic="True|False"             Font-Names="string"             Font-Overline="True|False"             Font-Size="string|Smaller|Larger|XX-Small|                        X-Small|Small|Medium|Large|X-Large|XX-Large"             Font-Strikeout="True|False"             Font-Underline="True|False"             ForeColor="color name|#dddddd"             GridLines="None|Horizontal|Vertical|Both"             Height="size"             HorizontalAlign="NotSet|Left|Center|Right|Justify"             OnDisposed="Disposed event handler"             Width="size"         />         <PartTitleStyle             BackColor="color name|#dddddd"             BorderColor="color name|#dddddd"             BorderStyle="NotSet|None|Dotted|Dashed|Solid|                         Double|Groove|Ridge|Inset|Outset"             BorderWidth="size"             CssClass="string"             Font-Bold="True|False"             Font-Italic="True|False"             Font-Names="string"             Font-Overline="True|False"             Font-Size="string|Smaller|Larger|XX-Small|                        X-Small|Small|Medium|Large|X-Large|XX-Large"             Font-Strikeout="True|False"             Font-Underline="True|False"             ForeColor="color name|#dddddd"             Height="size"             HorizontalAlign="NotSet|Left|Center|Right|Justify"             OnDisposed="Disposed event handler"             VerticalAlign="NotSet|Top|Middle|Bottom"             Width="size"             Wrap="True|False"         />         <VerbStyle />         <EditUIStyle />         <HeaderCloseVerb             Checked="True|False"             Description="string"             Enabled="True|False"             ImageUrl="uri"             Text="string"             Visible="True|False"         />         <HeaderVerbStyle />         <InstructionTextStyle />         <LabelStyle />         <CancelVerb             Checked="True|False"             Description="string"             Enabled="True|False"             ImageUrl="uri"             Text="string"             Visible="True|False"         />         <CloseVerb             Checked="True|False"             Description="string"             Enabled="True|False"             ImageUrl="uri"             Text="string"             Visible="True|False"         />         <ConfigureVerb             Checked="True|False"             Description="string"             Enabled="True|False"             ImageUrl="uri"             Text="string"             Visible="True|False"         />         <ConnectVerb             Checked="True|False"             Description="string"             Enabled="True|False"             ImageUrl="uri"             Text="string"             Visible="True|False"         />         <DisconnectVerb             Checked="True|False"             Description="string"             Enabled="True|False"             ImageUrl="uri"             Text="string"             Visible="True|False"         /> </asp:ConnectionsZone>

備註

使用 Web 組件控制項集合,您可以啟用兩個伺服器控制項以形成連接並共用資料,其中一個控制項做為資料提供者 (Data Provider),而另一個做為資料消費者 (Data Consumer)。兩個控制項都可以是 WebPart 控制項或任何其他類型的伺服器控制項,倘若它們是專為處理連接而設計且位於 WebPartZoneBase 區域中。

如需 ConnectionsZone 和 Web 組件控制項的詳細資訊,請參閱 ASP.NET Web 組件控制項

範例

下列程式碼範例示範如何在 Web 網頁上以宣告方式使用 ConnectionsZone 控制項。在項目中,一些屬性是以宣告方式設定的。在頁面的 script 區段中,連接區域上的其他屬性會以程式設計方式設定。

如需使用者控制項和以 @ Register 指示詞定義之自訂控制項的定義,請參閱 ConnectionsZone 類別概觀中的「範例」。

<%@ 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>
<%@ 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>

請參閱

參考

ConnectionsZone

其他資源

ASP.NET Web 組件控制項