ConnectionsZone 類別

定義

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

public ref class ConnectionsZone : System::Web::UI::WebControls::WebParts::ToolZone
public class ConnectionsZone : System.Web.UI.WebControls.WebParts.ToolZone
type ConnectionsZone = class
    inherit ToolZone
Public Class ConnectionsZone
Inherits ToolZone
繼承

範例

下列程式碼範例示範如何在網頁元件頁面上使用 ConnectionsZone 控制項。 此範例有四個部分:

  • 使用者控制項,可讓您在網頁上切換顯示模式。

  • 包含郵遞區號介面程式碼的來源檔案,以及兩 WebPart 個控制項做為連線的提供者和取用者。

  • 裝載所有控制項的網頁會示範如何宣告 <asp:connectionszone> 專案,並以宣告方式和以程式設計方式設定連接區域上的一些屬性。

  • 說明範例如何在瀏覽器中運作。

此程式碼範例的第一個部分是使用者控制項,可讓使用者切換網頁上的顯示模式。 如需此控制項中原始程式碼顯示模式和描述的詳細資訊,請參閱逐步解說 :變更網頁元件頁面上的顯示模式

<%@ control language="C#" classname="DisplayModeMenuCS"%>
<script runat="server">
  
 // Use a field to reference the current WebPartManager.
  WebPartManager _manager;

  void Page_Init(object sender, EventArgs e)
  {
    Page.InitComplete += new EventHandler(InitComplete);
  }  

  void InitComplete(object sender, System.EventArgs e)
  {
    _manager = WebPartManager.GetCurrentWebPartManager(Page);

    String browseModeName = WebPartManager.BrowseDisplayMode.Name;

    // Fill the dropdown with the names of supported display modes.
    foreach (WebPartDisplayMode mode in _manager.SupportedDisplayModes)
    {
      String modeName = mode.Name;
      // Make sure a mode is enabled before adding it.
      if (mode.IsEnabled(_manager))
      {
        ListItem item = new ListItem(modeName, modeName);
        DisplayModeDropdown.Items.Add(item);
      }
    }

    // If shared scope is allowed for this user, display the scope-switching
    // UI and select the appropriate radio button for the current user scope.
    if (_manager.Personalization.CanEnterSharedScope)
    {
      Panel2.Visible = true;
      if (_manager.Personalization.Scope == PersonalizationScope.User)
        RadioButton1.Checked = true;
      else
        RadioButton2.Checked = true;
    }
    
  }
 
  // Change the page to the selected display mode.
  void DisplayModeDropdown_SelectedIndexChanged(object sender, EventArgs e)
  {
    String selectedMode = DisplayModeDropdown.SelectedValue;

    WebPartDisplayMode mode = _manager.SupportedDisplayModes[selectedMode];
    if (mode != null)
      _manager.DisplayMode = mode;
  }

  // Set the selected item equal to the current display mode.
  void Page_PreRender(object sender, EventArgs e)
  {
    ListItemCollection items = DisplayModeDropdown.Items;
    int selectedIndex = 
      items.IndexOf(items.FindByText(_manager.DisplayMode.Name));
    DisplayModeDropdown.SelectedIndex = selectedIndex;
  }

  // Reset all of a user's personalization data for the page.
  protected void LinkButton1_Click(object sender, EventArgs e)
  {
    _manager.Personalization.ResetPersonalizationState();
  }

  // If not in User personalization scope, toggle into it.
  protected void RadioButton1_CheckedChanged(object sender, EventArgs e)
  {
    if (_manager.Personalization.Scope == PersonalizationScope.Shared)
      _manager.Personalization.ToggleScope();
  }

  // If not in Shared scope, and if user is allowed, toggle the scope.
  protected void RadioButton2_CheckedChanged(object sender, EventArgs e)
  {
    if (_manager.Personalization.CanEnterSharedScope && 
        _manager.Personalization.Scope == PersonalizationScope.User)
      _manager.Personalization.ToggleScope();
  }
</script>
<div>
  <asp:Panel ID="Panel1" runat="server" 
    Borderwidth="1" 
    Width="230" 
    BackColor="lightgray"
    Font-Names="Verdana, Arial, Sans Serif" >
    <asp:Label ID="Label1" runat="server" 
      Text=" Display Mode" 
      Font-Bold="true"
      Font-Size="8"
      Width="120" 
      AssociatedControlID="DisplayModeDropdown"/>
    <asp:DropDownList ID="DisplayModeDropdown" runat="server"  
      AutoPostBack="true" 
      Width="120"
      OnSelectedIndexChanged="DisplayModeDropdown_SelectedIndexChanged" />
    <asp:LinkButton ID="LinkButton1" runat="server"
      Text="Reset User State" 
      ToolTip="Reset the current user's personalization data for the page."
      Font-Size="8" 
      OnClick="LinkButton1_Click" />
    <asp:Panel ID="Panel2" runat="server" 
      GroupingText="Personalization Scope"
      Font-Bold="true"
      Font-Size="8" 
      Visible="false" >
      <asp:RadioButton ID="RadioButton1" runat="server" 
        Text="User" 
        AutoPostBack="true"
        GroupName="Scope" OnCheckedChanged="RadioButton1_CheckedChanged" />
      <asp:RadioButton ID="RadioButton2" runat="server" 
        Text="Shared" 
        AutoPostBack="true"
        GroupName="Scope" 
        OnCheckedChanged="RadioButton2_CheckedChanged" />
    </asp:Panel>
  </asp:Panel>
</div>
<%@ control language="vb" classname="DisplayModeMenuVB"%>
<script runat="server">
  ' Use a field to reference the current WebPartManager.
  Dim _manager As WebPartManager

  Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
    AddHandler Page.InitComplete, AddressOf InitComplete
  End Sub

  Sub InitComplete(ByVal sender As Object, ByVal e As System.EventArgs)
    _manager = WebPartManager.GetCurrentWebPartManager(Page)
      
    Dim browseModeName As String = WebPartManager.BrowseDisplayMode.Name
      
    ' Fill the dropdown with the names of supported display modes.
    Dim mode As WebPartDisplayMode
    For Each mode In _manager.SupportedDisplayModes
      Dim modeName As String = mode.Name
      ' Make sure a mode is enabled before adding it.
      If mode.IsEnabled(_manager) Then
        Dim item As New ListItem(modeName, modeName)
        DisplayModeDropdown.Items.Add(item)
      End If
    Next mode
      
    ' If shared scope is allowed for this user, display the scope-switching
    ' UI and select the appropriate radio button for the current user scope.
    If _manager.Personalization.CanEnterSharedScope Then
      Panel2.Visible = True
      If _manager.Personalization.Scope = PersonalizationScope.User Then
        RadioButton1.Checked = True
      Else
        RadioButton2.Checked = True
      End If
    End If
   
  End Sub

  ' Change the page to the selected display mode.
  Sub DisplayModeDropdown_SelectedIndexChanged(ByVal sender As Object, _
    ByVal e As EventArgs)
    
    Dim selectedMode As String = DisplayModeDropdown.SelectedValue   
    Dim mode As WebPartDisplayMode = _
      _manager.SupportedDisplayModes(selectedMode)
    If Not (mode Is Nothing) Then
      _manager.DisplayMode = mode
    End If

  End Sub
   
  ' Set the selected item equal to the current display mode.
  Sub Page_PreRender(ByVal sender As Object, ByVal e As EventArgs)
    Dim items As ListItemCollection = DisplayModeDropdown.Items
    Dim selectedIndex As Integer = _
      items.IndexOf(items.FindByText(_manager.DisplayMode.Name))
    DisplayModeDropdown.SelectedIndex = selectedIndex

  End Sub

  ' Reset all of a user's personalization data for the page.
  Protected Sub LinkButton1_Click(ByVal sender As Object, _
    ByVal e As EventArgs)
    
    _manager.Personalization.ResetPersonalizationState()
    
  End Sub

  ' If not in User personalization scope, toggle into it.
  Protected Sub RadioButton1_CheckedChanged(ByVal sender As Object, _
    ByVal e As EventArgs)
    
    If _manager.Personalization.Scope = PersonalizationScope.Shared Then
      _manager.Personalization.ToggleScope()
    End If

  End Sub
   
  ' If not in Shared scope, and if user is allowed, toggle the scope.
  Protected Sub RadioButton2_CheckedChanged(ByVal sender As Object, _
    ByVal e As EventArgs)
    
    If _manager.Personalization.CanEnterSharedScope AndAlso _
      _manager.Personalization.Scope = PersonalizationScope.User Then
      _manager.Personalization.ToggleScope()
    End If

  End Sub

</script>
<div>
  <asp:Panel ID="Panel1" runat="server" 
    Borderwidth="1" 
    Width="230" 
    BackColor="lightgray"
    Font-Names="Verdana, Arial, Sans Serif" >
    <asp:Label ID="Label1" runat="server" 
      Text=" Display Mode" 
      Font-Bold="true"
      Font-Size="8"
      Width="120" 
      AssociatedControlID="DisplayModeDropdown"/>
    <asp:DropDownList ID="DisplayModeDropdown" runat="server"  
      AutoPostBack="true" 
      Width="120"
      OnSelectedIndexChanged="DisplayModeDropdown_SelectedIndexChanged" />
    <asp:LinkButton ID="LinkButton1" runat="server"
      Text="Reset User State" 
      ToolTip="Reset the current user's personalization data for the page."
      Font-Size="8" 
      OnClick="LinkButton1_Click" />
    <asp:Panel ID="Panel2" runat="server" 
      GroupingText="Personalization Scope"
      Font-Bold="true"
      Font-Size="8" 
      Visible="false" >
      <asp:RadioButton ID="RadioButton1" runat="server" 
        Text="User" 
        AutoPostBack="true"
        GroupName="Scope" OnCheckedChanged="RadioButton1_CheckedChanged" />
      <asp:RadioButton ID="RadioButton2" runat="server" 
        Text="Shared" 
        AutoPostBack="true"
        GroupName="Scope" 
        OnCheckedChanged="RadioButton2_CheckedChanged" />
    </asp:Panel>
  </asp:Panel>
</div>

範例的第二個部分是具有 介面和自訂控制項的來源檔案。 請注意, ZipCodeWebPart 控制項會實作 IZipCode 介面,並新增 ConnectionProvider 屬性,讓控制項可以做為連線的提供者。 WeatherWebPart控制項具有標示為 ConnectionConsumer 屬性的方法,其會取用 IZipCode 介面,因此它可以做為連接中的取用者。

若要執行程式碼範例,您必須編譯此原始程式碼。 您可以明確地編譯它,並將產生的元件放在網站的 Bin 資料夾或全域組件快取中。 或者,您也可以將原始程式碼放在月臺的 App_Code 資料夾中,在執行時間會動態編譯原始程式碼。 此範例使用動態編譯。 如需示範如何編譯的逐步解說,請參閱逐步解說 :開發和使用自訂 Web 服務器控制項

namespace Samples.AspNet.CS.Controls
{
  using System;
  using System.Web;
  using System.Web.Security;
  using System.Security.Permissions;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using System.Web.UI.WebControls.WebParts;

  [AspNetHostingPermission(SecurityAction.Demand,
    Level = AspNetHostingPermissionLevel.Minimal)]
  [AspNetHostingPermission(SecurityAction.InheritanceDemand,
    Level = AspNetHostingPermissionLevel.Minimal)]
  public interface IZipCode
  {
    string ZipCode { get; set;}
  }

  [AspNetHostingPermission(SecurityAction.Demand,
    Level = AspNetHostingPermissionLevel.Minimal)]
  [AspNetHostingPermission(SecurityAction.InheritanceDemand,
    Level = AspNetHostingPermissionLevel.Minimal)]
  public class ZipCodeWebPart : WebPart, IZipCode
  {
    string zipCodeText = String.Empty;
    TextBox input;
    Button send;

    public ZipCodeWebPart()
    {
    }

    // Make the implemented property personalizable to save 
    // the Zip Code between browser sessions.
    [Personalizable()]
    public virtual string ZipCode
    {
      get { return zipCodeText; }
      set { zipCodeText = value; }
    }

    // This is the callback method that returns the provider.
    [ConnectionProvider("Zip Code Provider", "ZipCodeProvider")]
    public IZipCode ProvideIZipCode()
    {
      return this;
    }

    protected override void CreateChildControls()
    {
      Controls.Clear();
      input = new TextBox();
      this.Controls.Add(input);
      send = new Button();
      send.Text = "Enter 5-digit Zip Code";
      send.Click += new EventHandler(this.submit_Click);
      this.Controls.Add(send);
    }

    private void submit_Click(object sender, EventArgs e)
    {
      if (!string.IsNullOrEmpty(input.Text))
      {
        zipCodeText = Page.Server.HtmlEncode(input.Text);
        input.Text = String.Empty;
      }
    }
  }

  [AspNetHostingPermission(SecurityAction.Demand,
    Level = AspNetHostingPermissionLevel.Minimal)]
  [AspNetHostingPermission(SecurityAction.InheritanceDemand,
    Level = AspNetHostingPermissionLevel.Minimal)]
  public class WeatherWebPart : WebPart
  {
    private IZipCode _provider;
    string _zipSearch;
    Label DisplayContent;

    // This method is identified by the ConnectionConsumer 
    // attribute, and is the mechanism for connecting with 
    // the provider. 
    [ConnectionConsumer("Zip Code Consumer", "ZipCodeConsumer")]
    public void GetIZipCode(IZipCode Provider)
    {
      _provider = Provider;
    }
    
    protected override void OnPreRender(EventArgs e)
    {
      EnsureChildControls();

      if (this._provider != null)
      {
        _zipSearch = _provider.ZipCode.Trim();
        DisplayContent.Text = "My Zip Code is:  " + _zipSearch;
      }
    }

    protected override void CreateChildControls()
    {
      Controls.Clear();
      DisplayContent = new Label();
      this.Controls.Add(DisplayContent);
    }
  }
}
Imports System.Web
Imports System.Web.Security
Imports System.Security.Permissions
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts

Namespace Samples.AspNet.VB.Controls

  <AspNetHostingPermission(SecurityAction.Demand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
  <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
  Public Interface IZipCode

    Property ZipCode() As String

  End Interface

  <AspNetHostingPermission(SecurityAction.Demand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
  <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
  Public Class ZipCodeWebPart
    Inherits WebPart
    Implements IZipCode
    Private zipCodeText As String = String.Empty
    Private input As TextBox
    Private send As Button

    Public Sub New()
    End Sub

    ' Make the implemented property personalizable to save 
    ' the Zip Code between browser sessions.
    <Personalizable()> _
    Public Property ZipCode() As String _
      Implements IZipCode.ZipCode

      Get
        Return zipCodeText
      End Get
      Set(ByVal value As String)
        zipCodeText = value
      End Set
    End Property

    ' This is the callback method that returns the provider.
    <ConnectionProvider("Zip Code Provider", "ZipCodeProvider")> _
    Public Function ProvideIZipCode() As IZipCode
      Return Me
    End Function


    Protected Overrides Sub CreateChildControls()
      Controls.Clear()
      input = New TextBox()
      Me.Controls.Add(input)
      send = New Button()
      send.Text = "Enter 5-digit Zip Code"
      AddHandler send.Click, AddressOf Me.submit_Click
      Me.Controls.Add(send)

    End Sub


    Private Sub submit_Click(ByVal sender As Object, _
      ByVal e As EventArgs)

      If input.Text <> String.Empty Then
        zipCodeText = Page.Server.HtmlEncode(input.Text)
        input.Text = String.Empty
      End If

    End Sub

  End Class

  <AspNetHostingPermission(SecurityAction.Demand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
  <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
    Level:=AspNetHostingPermissionLevel.Minimal)> _
  Public Class WeatherWebPart
    Inherits WebPart
    Private _provider As IZipCode
    Private _zipSearch As String
    Private DisplayContent As Label

    ' This method is identified by the ConnectionConsumer 
    ' attribute, and is the mechanism for connecting with 
    ' the provider. 
    <ConnectionConsumer("Zip Code Consumer", "ZipCodeConsumer")> _
    Public Sub GetIZipCode(ByVal Provider As IZipCode)
      _provider = Provider
    End Sub


    Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
      EnsureChildControls()

      If Not (Me._provider Is Nothing) Then
        _zipSearch = _provider.ZipCode.Trim()
                DisplayContent.Text = "My Zip Code is:  " + _zipSearch
      End If

    End Sub

    Protected Overrides Sub CreateChildControls()
      Controls.Clear()
      DisplayContent = New Label()
      Me.Controls.Add(DisplayContent)

    End Sub

  End Class

End Namespace

範例程式碼的第三個部分是網頁。 靠近頂端是 Register 使用者控制項的指示詞,以及連接中使用的自訂控制項。 元素 <asp:connectionszone> 會在頁面中宣告為以宣告方式使用 ConnectionsZone 控制項的範例。 在 元素內,會以宣告方式設定許多屬性。 連線區域的其他屬性會在頁面的 區段中以程式設計方式 <script> 設定。

<%@ 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 來選取連接點並建立連線。

備註

使用 Web 元件控制項集,您可以啟用兩個伺服器控制項來形成連線和共用資料,其中一個控制項做為提供者,另一個控制項則做為資料的取用者。 這兩個控制項可以是 WebPart 控制項或任何其他類型的伺服器控制項,前提是它們的設計目的是要處理連線,而且它們位於 WebPartZoneBase 區域中。 若要深入瞭解網頁元件連線,請參閱 WebPartConnectionConnectionPoint 類別概觀,以及 Web 元件連線概觀

前提是必要控制項和條件存在以形成網頁元件連線,您仍然需要實際連接控制項。 有三種方式可在伺服器控制項之間建立連線:在網頁中宣告連線、在程式碼中建立連線,或將控制項新增 ConnectionsZone 至頁面,讓使用者可以視需要連接控制項。 控制項 ConnectionsZone 會產生 UI,讓使用者能夠連接或中斷頁面上符合形成連線所需條件的任何伺服器控制項。 這是表單連接不需要的選擇性控制項,但在您想要讓使用者控制連線或中斷連線的伺服器控制項時很有用。

控制項 ConnectionsZone 是繼承自 ToolZone 基類的其中一個 Web 元件工具區域控制項。 做為工具區域, ConnectionsZone 只有當控制項的網頁處於特定顯示模式時,控制項才會被設計為可見。 在此情況下,當頁面上的控制項的 DisplayMode 屬性值設定為) 時 WebPartManager ,頁面會 (處於此模式的顯示模式命名為 ConnectDisplayMode connect 模式。 當使用者將頁面切換為連線模式之後,他們必須在其中一個伺服器控制項的動詞功能表上按一下連接動詞,然後連接 UI 就會變成可見。

做為網頁元件區域控制項, ConnectionsZone 控制項是一種 WebZone 區域 (,其繼承自 CompositeControl 設計成包含其他控制項的類別) 。 一般而言, ConnectionsZone 區域具有與其他網頁元件工具區域相同的大部分元素:標頭、本文或內容區域,以及頁尾。 如需網頁元件區域和區域不同部分的完整討論,請參閱 WebZone 類別概觀。

重要

不同于其他大部分的網頁元件區域,請務必注意 ConnectionsZone 區域不包含與其相關聯的唯一伺服器控制項類型。 如需區域清單及其包含的相關控制項,請參閱類別概觀中的 WebZone 圖表。 ConnectionsZone但區域不包含 WebPartConnection 控制項。 相反地,它提供一個非常有限的用途,讓使用者連線或中斷存在於頁面上某些 WebPartZoneBase 區域中的伺服器控制項連線或中斷連線。 控制項中唯一 ConnectionsZone 包含的控制項是標準 ASP.NET 伺服器控制項,其會作為其 UI 的一部分來形成連線。

ConnectionsZone轉譯控制項時,它會根據頁面上能夠形成連線的伺服器控制項產生 UI。 控制項 ConnectionsZone 會決定頁面上區域中哪些伺服器控制項 WebPartZoneBase 是提供者、哪些是取用者、哪些連接點可供使用,以及伺服器控制項目前是否已連線或中斷連線,然後據以產生 UI。

例如,假設有一個控制項能夠成為提供者、一個 WebPartWebPart 能夠成為取用者的控制項、在頁面上宣告 WebPartZone 它們,而且目前已中斷連線。 當使用者將頁面切換為連線模式,並按一下其中一個控制項上的連接動詞時, ConnectionsZone 控制項會產生具有連結的 UI,按一下時會顯示表單,讓使用者可以選擇建立連線的選項。 (如果先前已連接控制項,則初始檢視會改為向使用者顯示按鈕來中斷控制項) 。 在建立新連線的連線 UI 中,使用者會顯示哪些控制項是提供者,以及哪個控制項是取用者。 下拉式清單控制項會出現在每個伺服器控制項下方,列出控制項的可用 ConnectionPoint 物件。 從個別的下拉式清單中,使用者必須為提供者選取一個 ProviderConnectionPoint 物件 (,以判斷要與取用者共用的介面和資料) ,以及每個取用者 (一個 ConsumerConnectionPoint 物件,以判斷取用者將取用哪些介面和資料) 連線至提供者。

注意

在 Web 元件控制項集預設實作中,一個提供者可以連線到許多取用者,但取用者只能有一個提供者。

若要使用 ConnectionsZone 控制項,您可以在網頁上的 元素內 <form> 宣告它, (但不巢狀于另一個 Web 元件區域元素內,) <asp:connectionszone> 使用 元素,或者您可以透過程式設計方式將它新增至頁面。 如果您在頁面中宣告元素,不同于其他網頁元件區域,您無法在元素的 <asp:connectionszone> 標記之間宣告任何其他類型的伺服器控制項。 您可以宣告與其本身屬性和樣式詳細資料相關的元素,但它是獨立元素,而且不是可宣告其他伺服器控制項的範本控制項。

注意

為了改善協助工具, ConnectionsZone 控制項會在 元素內 <fieldset> 呈現。 元素會將 <fieldset> 用於在控制項中 ConnectionsZone 建立連線的相關控制項集分組,並協助在視覺使用者代理程式 (的這些控制項之間,進行索引標籤式導覽,例如一般網頁瀏覽器) 和語音導向使用者代理程式, (例如螢幕閱讀軟體) 。

控制項 ConnectionsZone 有一些用於轉譯連接 UI 的屬性。 其中一組屬性包含數個動詞--僅用於連接-- 在 UI 中執行動作: ConfigureVerbConnectVerbDisconnectVerb 。 特別用於連接區域 UI 的大型屬性集是由各種位置 (或在特定情況下顯示的文字字串所組成,例如在 UI 中發生錯誤) 時: ConfigureConnectionTitleConnectToConsumerInstructionTextNewConnectionErrorMessageGetTextConnectToConsumerTextConnectToProviderTitleConsumersInstructionTextConnectToProviderTextConsumersTitleConnectToProviderInstructionTextExistingConnectionErrorMessageNoExistingConnectionTitleInstructionTitleGetFromTextConnectToConsumerTitleProvidersInstructionTextProvidersTitleNoExistingConnectionInstructionText 、、、 SendText 和 。 SendToText 類別 ConnectionsZone 也包含其他網頁元件區域中的一些常見屬性: CancelVerbCloseVerbDisplayEmptyZoneText 、、 HeaderTextInstructionTextPartChromeType 。 最後, WebPartToConnect 屬性對 類別而言是唯一的,參考起始連接的控制項 (這是使用者在其動詞功能表中按一下連接動詞動詞的控制項,這也是控制項屬性中所 WebPartManager 參考的 SelectedWebPart 控制項) 。

類別 ConnectionsZone 也有一些方法,這些方法全都是繼承和覆寫自基類,其中大部分都是來自基底 Web 元件區域類別。 如需詳細資訊,請參閱個別方法。

給繼承者的注意事項

ConnectionsZone如果開發人員想要變更其行為或它提供用來處理連線的預設 UI,則可以擴充 類別。

建構函式

ConnectionsZone()

初始化 ConnectionsZone 類別的新執行個體。

屬性

AccessKey

取得或設定便捷鍵 (Access Key),可讓您快速巡覽至 Web 伺服器控制項。

(繼承來源 WebControl)
Adapter

針對控制項取得瀏覽器的特定配置器。

(繼承來源 Control)
AppRelativeTemplateSourceDirectory

取得或設定包含了此控制項之 PageUserControl 物件的相對應用程式虛擬目錄。

(繼承來源 Control)
AssociatedDisplayModes

取得與特定 WebPartDisplayMode 區域相關聯的 ToolZone 物件集合。

(繼承來源 ToolZone)
Attributes

取得任意屬性 (Attribute) 的集合 (只供呈現),不與控制項上的屬性 (Property) 對應。

(繼承來源 WebControl)
BackColor

取得或設定 Web 伺服器控制項的背景色彩。

(繼承來源 WebControl)
BackImageUrl

取得或設定區域背景影像的 URL。

(繼承來源 WebZone)
BindingContainer

取得包含了此控制項之資料繫結的控制項。

(繼承來源 Control)
BorderColor

取得或設定 Web 控制項的框線色彩。

(繼承來源 WebControl)
BorderStyle

取得或設定 Web 伺服器控制項的框線樣式。

(繼承來源 WebControl)
BorderWidth

取得或設定 Web 伺服器控制項的框線寬度。

(繼承來源 WebControl)
CancelVerb

取得 WebPartVerb 物件的參考,這個物件可讓使用者取消建立連接的程序。

ChildControlsCreated

取得值,指出是否已經建立伺服器控制項的子控制項。

(繼承來源 Control)
ClientID

取得 ASP.NET 所產生之 HTML 標記的控制項識別碼。

(繼承來源 Control)
ClientIDMode

取得或設定用來產生 ClientID 屬性值的演算法。

(繼承來源 Control)
ClientIDSeparator

取得字元值,表示在 ClientID 屬性中所使用的分隔字元。

(繼承來源 Control)
CloseVerb

取得 WebPartVerb 物件的參考,該物件可讓使用者關閉 ConnectionsZone 控制項所建立的連接使用者介面 (UI)。

ConfigureConnectionTitle

取得或設定文字,此文字會顯示為 ConnectionsZone 控制項所建立之連接使用者介面 (UI) 子區段的標題。

ConfigureVerb

取得 WebPartVerb 物件的參考,這個物件是用來開啟連接使用者介面 (UI) 中的組態檢視。

ConnectToConsumerInstructionText

取得或設定連接使用者介面 (UI) 區段中所顯示的指示文字,在這個區段中使用者可以選取提供者將連接到的消費者連接點。

ConnectToConsumerText

取得或設定超連結的文字,使用者按一下此超連結時,會開啟可供選擇連接之消費者控制項的檢視。

ConnectToConsumerTitle

取得或設定連接使用者介面 (UI) 的區段標題文字,在此區段中使用者可以選取要連接的特定消費者。

ConnectToProviderInstructionText

取得或設定連接使用者介面 (UI) 區段中所顯示的指示文字,在這個區段中使用者可以選取消費者將連接到的提供者連接點。

ConnectToProviderText

取得或設定超連結的文字,使用者按一下此超連結時,會開啟可供選擇連接之提供者控制項的檢視。

ConnectToProviderTitle

取得或設定連接使用者介面 (UI) 的區段標題文字,在此區段中使用者可以選取要連接的特定提供者。

ConnectVerb

取得 WebPartVerb 物件的參考,這個物件可讓兩個 WebPart 控制項建立連接。

ConsumersInstructionText

當連接已存在時,取得或設定連接使用者介面 (UI) 的消費者區段中所顯示的指示文字。

ConsumersTitle

當連接已存在時,取得或設定連接使用者介面 (UI) 的消費者區段上方所顯示的標題。

Context

取得與目前 Web 要求的伺服器控制項關聯的 HttpContext 物件。

(繼承來源 Control)
Controls

取得表示 ControlCollection 中之子控制項的 CompositeControl 物件。

(繼承來源 CompositeControl)
ControlStyle

取得 Web 伺服器控制項的樣式。 這個屬性主要由控制項開發人員使用。

(繼承來源 WebControl)
ControlStyleCreated

取得值,指出 Style 物件是否已經為 ControlStyle 屬性建立。 這個屬性主要由控制項開發人員使用。

(繼承來源 WebControl)
CssClass

取得或設定用戶端上 Web 伺服器控制項所呈現的階層式樣式表 (CSS)。

(繼承來源 WebControl)
DataItemContainer

如果命名容器實作 IDataItemContainer,則取得命名容器的參考。

(繼承來源 Control)
DataKeysContainer

如果命名容器實作 IDataKeysControl,則取得命名容器的參考。

(繼承來源 Control)
DesignMode

取得值,指出控制項是否正用於設計介面上。

(繼承來源 Control)
DisconnectVerb

取得 WebPartVerb 物件的參考,這個物件可讓使用者中斷兩個 WebPart 控制項之間的連接。

Display

取得值,其中該值指出目前是否顯示 ToolZone 控制項。

EditUIStyle

取得 ToolZone 控制項包含之控制項的樣式屬性。

(繼承來源 ToolZone)
EmptyZoneText

如果網頁上控制項不足,無法建立連接時,取得或設定空 ConnectionsZone 控制項中所顯示的文字訊息。

EmptyZoneTextStyle

取得空區域中替代符號文字的樣式屬性。

(繼承來源 WebZone)
Enabled

取得或設定值,指出 Web 伺服器控制項是否啟用。

(繼承來源 WebControl)
EnableTheming

取得或設定值,指出佈景主題是否套用至此控制項。

(繼承來源 WebControl)
EnableViewState

取得或設定值,該值表示伺服器控制項是否對要求的用戶端而言保持其檢視狀態,以及它包含的任何子控制項狀態。

(繼承來源 Control)
ErrorStyle

取得呈現錯誤訊息的樣式屬性,無法載入或建立 WebPart 控制項時會顯示該錯誤訊息。

(繼承來源 WebZone)
Events

取得控制項事件處理常式委派 (Delegate) 的清單。 這個屬性是唯讀的。

(繼承來源 Control)
ExistingConnectionErrorMessage

當現有連接上有錯誤或警告時,取得或設定連接使用者介面 (UI) 中所顯示的訊息文字。

Font

取得與 Web 伺服器控制項關聯的字型屬性。

(繼承來源 WebControl)
FooterStyle

取得區域頁尾區內容的樣式屬性。

(繼承來源 WebZone)
ForeColor

取得或設定 Web 伺服器控制項的前景色彩 (通常是文字的色彩)。

(繼承來源 WebControl)
GetFromText

取得或設定連接使用者介面 (UI) 區段中所顯示的文字,此文字位在消費者將從中擷取資料的具名提供者之前。

GetText

取得或設定連接使用者介面 (UI) 區段中所顯示的文字,此文字位在將從提供者接收資料的具名消費者之前。

HasAttributes

取得值,指出控制項是否已經設定屬性。

(繼承來源 WebControl)
HasChildViewState

取得值,指出目前伺服器控制項的子控制項是否有任何已儲存的檢視狀態設定。

(繼承來源 Control)
HasFooter

取得值,表示區域是否具有頁尾區。

(繼承來源 WebZone)
HasHeader

取得值,表示區域是否具有頁首區。

(繼承來源 WebZone)
HeaderCloseVerb

取得 WebPartVerb 控制項頁首中 ToolZone 物件的參考,該物件用於關閉控制項。

(繼承來源 ToolZone)
HeaderStyle

取得區域頁首區內容的樣式屬性。

(繼承來源 WebZone)
HeaderText

取得或設定出現在 ConnectionsZone 控制項所建立之連接使用者介面 (UI) 頂端的標頭文字。

HeaderVerbStyle

取得顯示於 ToolZone 控制項中所有頁首動詞命令的樣式屬性。

(繼承來源 ToolZone)
Height

取得或設定 Web 伺服器控制項的高度。

(繼承來源 WebControl)
ID

取得或設定指派給伺服器控制項的程式設計識別項。

(繼承來源 Control)
IdSeparator

取得用來分隔控制項識別項的字元。

(繼承來源 Control)
InstructionText

取得或設定文字,在管理現有連接之連接使用者介面 (UI) 區段中,選取之控制項的一般指示使用此文字。

InstructionTextStyle

取得顯示在 ToolZone 控制項頂端之指示文字的樣式屬性。

(繼承來源 ToolZone)
InstructionTitle

取得或設定文字,在管理現有連接的連接使用者介面 (UI) 中,對消費者或提供者控制項可執行之動作的一般描述會使用此文字。

IsChildControlStateCleared

取得值,指出這個控制項中所包含的控制項是否有控制項狀態。

(繼承來源 Control)
IsEnabled

取得值,指出是否啟用控制項。

(繼承來源 WebControl)
IsTrackingViewState

取得值,指出伺服器控制項是否正在儲存檢視狀態的變更。

(繼承來源 Control)
IsViewStateEnabled

取得值,指出這個控制項是否已啟用檢視狀態。

(繼承來源 Control)
LabelStyle

取得標籤內容的樣式屬性,該標籤顯示在 ToolZone 控制項中的編輯控制項旁。 衍生的 ToolZone 控制項 (例如 CatalogZoneEditorZone) 會將樣式套用至標籤。

(繼承來源 ToolZone)
LoadViewStateByID

取得值,指出控制項是否依 ID (而不是索引) 參與載入其檢視狀態。

(繼承來源 Control)
NamingContainer

取得伺服器控制項命名容器的參考,其建立唯一命名空間,在具有相同 ID 屬性值的伺服器控制項之間作區別。

(繼承來源 Control)
NewConnectionErrorMessage

當使用者嘗試建立的新連接上有錯誤或警告時,取得或設定連接使用者介面 (UI) 中所顯示的訊息文字。

NoExistingConnectionInstructionText

當 Web 組件控制項沒有現有連接時,取得或設定在連接使用者介面 (UI) 主體中出現的指示文字。

NoExistingConnectionTitle

當 Web 組件控制項沒有現有連接時,取得或設定在連接使用者介面 (UI) 主體中出現的標題文字。

Padding

取得或設定表格的儲存格填補屬性,該表格包含區域的 WebPart 控制項。

(繼承來源 WebZone)
Page

取得含有伺服器控制項的 Page 執行個體的參考。

(繼承來源 Control)
Parent

在網頁控制階層架構中取得伺服器控制項之父控制項的參考。

(繼承來源 Control)
PartChromePadding

取得或設定 WebPart 控制項的內容與此控制項的框線之間的距離。

(繼承來源 WebZone)
PartChromeStyle

取得樣式特性,該樣式特性套用至區域中 Web 組件控制項的框線。

(繼承來源 WebZone)
PartChromeType

取得或設定架構 ConnectionsZone 控制項中所包含之伺服器控制項的框線類型。

PartStyle

取得樣式特性,該樣式特性套用至區域中每個 Web 組件控制項的框線和內容。

(繼承來源 WebZone)
PartTitleStyle

取得區域中每個 Web 組件控制項標題列內容的樣式屬性。

(繼承來源 WebZone)
ProvidersInstructionText

當連接已存在時,取得或設定連接使用者介面 (UI) 的提供者區段中所顯示的指示文字。

ProvidersTitle

當連接已存在時,取得或設定連接使用者介面 (UI) 的提供者區段上方所顯示的標題。

RenderClientScript

取得值,指出是否在 Web 組件頁面上呈現用戶端指令碼。

(繼承來源 WebZone)
RenderingCompatibility

取得值,這個值會指定將與呈現 HTML 相容的 ASP.NET 版本。

(繼承來源 Control)
SendText

取得或設定連接使用者介面 (UI) 區段中所顯示的文字,此文字位在將傳送資料至消費者的具名提供者之前。

SendToText

取得或設定連接使用者介面 (UI) 區段中所顯示的文字,此文字位在提供者將傳送資料至的具名消費者之前。

Site

當呈現在設計介面上時,取得裝載目前控制項之容器的資訊。

(繼承來源 Control)
SkinID

取得或設定要套用至控制項的面板。

(繼承來源 WebControl)
Style

取得文字屬性的集合,將呈現為 Web 伺服器控制項的外部標記上的樣式屬性。

(繼承來源 WebControl)
SupportsDisabledAttribute

取得值,這個值表示當控制項的 disabled 屬性為 IsEnabled 時,控制項是否應該將呈現之 HTML 項目的 false 屬性設為 "disabled"。

(繼承來源 CompositeControl)
TabIndex

取得或設定 Web 伺服器控制項的定位索引。

(繼承來源 WebControl)
TagKey

取得對應至這個 Web 伺服器控制項的 HtmlTextWriterTag 值。 這個屬性主要由控制項開發人員使用。

(繼承來源 WebZone)
TagName

取得控制項標記的名稱。 這個屬性主要由控制項開發人員使用。

(繼承來源 WebControl)
TemplateControl

取得或設定包含了此控制項之樣板的參考。

(繼承來源 Control)
TemplateSourceDirectory

取得包含目前伺服器控制項的 PageUserControl 的虛擬目錄。

(繼承來源 Control)
ToolTip

取得或設定當滑鼠指標停留在 Web 伺服器控制項時顯示的文字。

(繼承來源 WebControl)
UniqueID

取得伺服器控制項唯一的、符合階層架構的識別項。

(繼承來源 Control)
ValidateRequestMode

取得或設定值,指出控制項是否對來自瀏覽器的用戶端輸入檢查潛在的危險值。

(繼承來源 Control)
VerbButtonType

取得或設定用於表示區域動詞命令的按鈕類型。

(繼承來源 WebZone)
VerbStyle

取得使用者介面 (UI) 動詞命令的樣式屬性,該動詞命令與區域中的 Web 組件控制項相關聯。

(繼承來源 WebZone)
ViewState

取得狀態資訊的字典,允許您在相同網頁的多個要求之間,儲存和還原伺服器控制項的檢視狀態。

(繼承來源 Control)
ViewStateIgnoresCase

取得值,指出 StateBag 物件是否不區分大小寫。

(繼承來源 Control)
ViewStateMode

取得或設定這個控制項的檢視狀態模式。

(繼承來源 Control)
Visible

取得或設定值,指出伺服器控制項是否要呈現為網頁上的使用者介面 (UI) 項目。

(繼承來源 ToolZone)
WebPartManager

取得 WebPartManager 控制項的參考,該控制項與 Web 組件頁面上的 WebZone 控制項執行個體相關聯。

(繼承來源 WebZone)
WebPartToConnect

取得目前選取的 WebPart 控制項以連接。

Width

取得或設定 Web 伺服器控制項的寬度。

(繼承來源 WebControl)

方法

AddAttributesToRender(HtmlTextWriter)

將需要呈現的 HTML 屬性和樣式加入至指定的 HtmlTextWriterTag 中。 這個方法主要由控制項開發人員使用。

(繼承來源 WebControl)
AddedControl(Control, Int32)

在子控制項加入 Control 物件的 Controls 集合後呼叫。

(繼承來源 Control)
AddParsedSubObject(Object)

通知伺服器控制項,XML 或 HTML 項目已剖析,並將項目加入伺服器控制項的 ControlCollection 物件中。

(繼承來源 Control)
ApplyStyle(Style)

將指定樣式的任何非空白項目加入到 Web 控制項中,覆寫控制項的任何現有的樣式項目。 這個方法主要由控制項開發人員使用。

(繼承來源 WebControl)
ApplyStyleSheetSkin(Page)

將頁面樣式表中所定義的樣式屬性套用至控制項。

(繼承來源 Control)
BeginRenderTracing(TextWriter, Object)

開始進行轉譯資料的設計階段追蹤。

(繼承來源 Control)
BuildProfileTree(String, Boolean)

收集伺服器控制項的相關資訊,並在頁面啟用追蹤時將此資訊傳遞至 Trace 屬性以顯示之。

(繼承來源 Control)
ClearCachedClientID()

將快取的 ClientID 值設定為 null

(繼承來源 Control)
ClearChildControlState()

刪除伺服器控制項之子控制項的控制項狀態資訊。

(繼承來源 Control)
ClearChildState()

刪除所有伺服器控制項之子控制項的檢視狀態和控制項狀態資訊。

(繼承來源 Control)
ClearChildViewState()

刪除所有伺服器控制項之子控制項的檢視狀態資訊。

(繼承來源 Control)
ClearEffectiveClientIDMode()

將目前的控制項執行個體和任何子控制項的 ClientIDMode 屬性設定為 Inherit

(繼承來源 Control)
Close()

關閉 ConnectionsZone 控制項所建立的連接使用者介面 (UI)。

CopyBaseAttributes(WebControl)

將不被 Style 物件封裝的屬性從指定的 Web 伺服器控制項複製到呼叫這個方法的 Web 伺服器控制項上。 這個方法主要由控制項開發人員使用。

(繼承來源 WebControl)
CreateChildControls()

建立 ConnectionsZone 控制項中所包含的所有子控制項,以準備回傳至伺服器或呈現。

CreateControlCollection()

建立新的 ControlCollection 物件來保存伺服器控制項的子控制項 (常值和伺服器)。

(繼承來源 Control)
CreateControlStyle()

建立樣式物件,這個物件被 WebControl 類別內部使用,以實作所有的樣式相關屬性。 這個方法主要由控制項開發人員使用。

(繼承來源 WebControl)
DataBind()

繫結資料來源至 CompositeControl 以及其所有子控制項。

(繼承來源 CompositeControl)
DataBind(Boolean)

使用會引發 DataBinding 事件的選項,繫結資料來源至叫用的伺服器控制項及其所有子控制項。

(繼承來源 Control)
DataBindChildren()

繫結資料來源至伺服器控制項的子控制項。

(繼承來源 Control)
Dispose()

啟用伺服器控制項,在它從記憶體釋放之前執行最後清除。

(繼承來源 Control)
EndRenderTracing(TextWriter, Object)

結束轉譯資料的設計階段追蹤。

(繼承來源 Control)
EnsureChildControls()

判斷伺服器控制項是否包含子控制項。 如果不包含,則建立子控制項。

(繼承來源 Control)
EnsureID()

為尚未指定識別項的控制項,建立識別項。

(繼承來源 Control)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
FindControl(String)

在目前命名容器搜尋具有指定 id 參數的伺服器控制項。

(繼承來源 Control)
FindControl(String, Int32)

使用指定的 id 和有助於搜尋之 pathOffset 參數中所指定的整數,在目前的命名容器中搜尋伺服器控制項。 您不應該覆寫這個版本的 FindControl 方法。

(繼承來源 Control)
Focus()

設定控制項的輸入焦點。

(繼承來源 Control)
GetDesignModeState()

取得控制項的設計階段資料。

(繼承來源 Control)
GetEffectiveChromeType(Part)

如果提供區域 PartChromeType 屬性和 Web 組件頁面的目前顯示模式,則會傳回 WebPart 控制項之實際或有效的目前 PartChromeType 值。

(繼承來源 WebZone)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetRouteUrl(Object)

取得會對應於一組路由參數的 URL。

(繼承來源 Control)
GetRouteUrl(RouteValueDictionary)

取得會對應於一組路由參數的 URL。

(繼承來源 Control)
GetRouteUrl(String, Object)

取得 URL,此 URL 對應於一組路由參數及一個路由名稱。

(繼承來源 Control)
GetRouteUrl(String, RouteValueDictionary)

取得 URL,此 URL 對應於一組路由參數及一個路由名稱。

(繼承來源 Control)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
GetUniqueIDRelativeTo(Control)

傳回指定之控制項 UniqueID 屬性的前置部分。

(繼承來源 Control)
HasControls()

判斷伺服器控制項是否包含任何子控制項。

(繼承來源 Control)
HasEvents()

傳回值,指出控制項或任何子控制項的事件是否已註冊。

(繼承來源 Control)
IsLiteralContent()

判斷伺服器控制項是否只儲存常值內容。

(繼承來源 Control)
LoadControlState(Object)

SaveControlState() 方法所儲存的上一頁要求中,還原控制項狀態資訊。

LoadViewState(Object)

SaveViewState() 方法所儲存的先前頁面要求來還原檢視狀態資訊。

MapPathSecure(String)

擷取虛擬絕對路徑或相對路徑所對應至的實體路徑。

(繼承來源 Control)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
MergeStyle(Style)

將指定樣式的任何非空白項目複製到 Web 控制項,但不覆寫控制項的任何現有樣式項目。 這個方法主要由控制項開發人員使用。

(繼承來源 WebControl)
OnBubbleEvent(Object, EventArgs)

決定伺服器控制項的事件是否要在頁面的 UI 伺服器控制項階層架構中向上傳遞。

(繼承來源 Control)
OnDataBinding(EventArgs)

引發 DataBinding 事件。

(繼承來源 Control)
OnDisplayModeChanged(Object, WebPartDisplayModeEventArgs)

引發 DisplayModeChanged 事件。

OnInit(EventArgs)

引發 Init 事件。

OnLoad(EventArgs)

引發 Load 事件。

(繼承來源 Control)
OnPreRender(EventArgs)

引發 PreRender 事件。

(繼承來源 WebZone)
OnSelectedWebPartChanged(Object, WebPartEventArgs)

引發 SelectedWebPartChanged 事件。

OnUnload(EventArgs)

引發 Unload 事件。

(繼承來源 Control)
OpenFile(String)

取得用來讀取檔案的 Stream

(繼承來源 Control)
RaiseBubbleEvent(Object, EventArgs)

指派事件的任何來源和它的資訊至控制項的父控制項。

(繼承來源 Control)
RaisePostBackEvent(String)

引發 ConnectionsZone 控制項的事件,當包含此控制項的表單回傳至伺服器之時。

RecreateChildControls()

重新建立衍生自 CompositeControl 之控制項的子控制項。

(繼承來源 CompositeControl)
RemovedControl(Control)

Control 物件的 Controls 集合中移除子控制項之後呼叫。

(繼承來源 Control)
Render(HtmlTextWriter)

ConnectionsZone 控制項的內容呈現為指定的 HtmlTextWriter 物件。

RenderBeginTag(HtmlTextWriter)

將區域控制項的開頭 HTML 標記呈現至指定的 HtmlTextWriter 物件。

(繼承來源 WebZone)
RenderBody(HtmlTextWriter)

ConnectionsZone 控制項的主體區域內容傳送至指定的 HtmlTextWriter 物件,再由此物件將內容寫入網頁。

RenderChildren(HtmlTextWriter)

將伺服器控制項子系的內容輸出至提供的 HtmlTextWriter 物件,再由這個物件在用戶端上寫入要轉譯的內容。

(繼承來源 Control)
RenderContents(HtmlTextWriter)

將區域控制項的整個內容 (開始和結束標記之間的部分) 呈現至指定的 HtmlTextWriter 物件。

(繼承來源 WebZone)
RenderControl(HtmlTextWriter)

將伺服器控制項內容輸出至提供的 HtmlTextWriter 物件,並在啟用追蹤時儲存控制項的追蹤資訊。

(繼承來源 Control)
RenderControl(HtmlTextWriter, ControlAdapter)

使用提供的 HtmlTextWriter 物件,輸出伺服器控制項內容至提供的 ControlAdapter 物件。

(繼承來源 Control)
RenderEndTag(HtmlTextWriter)

將控制項的 HTML 結尾標記呈現至指定的寫入器。 這個方法主要由控制項開發人員使用。

(繼承來源 WebControl)
RenderFooter(HtmlTextWriter)

覆寫基底方法,呈現 ToolZone 控制項頁尾的動詞命令。

(繼承來源 ToolZone)
RenderHeader(HtmlTextWriter)

覆寫基底方法,提供 ToolZone 控制項所需之頁首區的特定呈現。

(繼承來源 ToolZone)
RenderVerb(HtmlTextWriter, WebPartVerb)

呈現 ToolZone 控制項的個別動詞命令。

(繼承來源 ToolZone)
RenderVerbs(HtmlTextWriter)

呈現 ConnectionsZone 控制項的區域層次動詞命令。

ResolveAdapter()

取得負責呈現指定之控制項的控制項配置器。

(繼承來源 Control)
ResolveClientUrl(String)

取得瀏覽器可使用的 URL。

(繼承來源 Control)
ResolveUrl(String)

將 URL 轉換為要求用戶端可使用的 URL。

(繼承來源 Control)
SaveControlState()

儲存從網頁上次回傳到伺服器以來所發生的任何 Web 組件控制項狀態變更。

SaveViewState()

儲存自從網頁上次回傳至伺服器以來所發生的 ConnectionsZone 控制項檢視狀態變更。

SetDesignModeState(IDictionary)

設定控制項的設計階段資料。

(繼承來源 Control)
SetRenderMethodDelegate(RenderMethod)

指定事件處理常式委派,以呈現伺服器控制項及其內容至其父控制項。

(繼承來源 Control)
SetTraceData(Object, Object)

使用追蹤資料機碼和追蹤資料值,設定設計階段期間追蹤呈現資料的追蹤資料。

(繼承來源 Control)
SetTraceData(Object, Object, Object)

使用追蹤的物體、追蹤資料機碼和追蹤資料值,設定設計階段期間追蹤呈現資料的追蹤資料。

(繼承來源 Control)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)
TrackViewState()

追蹤 ConnectionsZone 控制項的檢視狀態變更,讓變更能夠儲存在控制項的 StateBag 物件中。

事件

DataBinding

發生於伺服器控制項繫結至資料來源時。

(繼承來源 Control)
Disposed

發生於伺服器控制項從記憶體釋放時,這是在要求 ASP.NET 網頁時,伺服器控制項生命週期的最後階段。

(繼承來源 Control)
Init

發生於初始化伺服器控制項時,是其生命週期中的第一個步驟。

(繼承來源 Control)
Load

發生於載入伺服器控制項至 Page 物件時。

(繼承來源 Control)
PreRender

Control 物件載入之後但在呈現之前發生。

(繼承來源 Control)
Unload

發生於伺服器控制項從記憶體卸載時。

(繼承來源 Control)

明確介面實作

IAttributeAccessor.GetAttribute(String)

使用指定的名稱,取得 Web 控制項的屬性。

(繼承來源 WebControl)
IAttributeAccessor.SetAttribute(String, String)

將 Web 控制項的屬性設定為指定的名稱和值。

(繼承來源 WebControl)
ICompositeControlDesignerAccessor.RecreateChildControls()

讓設計工具能在設計階段環境中重新建立複合控制項的子控制項集合。

(繼承來源 CompositeControl)
IControlBuilderAccessor.ControlBuilder

如需這個成員的說明,請參閱 ControlBuilder

(繼承來源 Control)
IControlDesignerAccessor.GetDesignModeState()

如需這個成員的說明,請參閱 GetDesignModeState()

(繼承來源 Control)
IControlDesignerAccessor.SetDesignModeState(IDictionary)

如需這個成員的說明,請參閱 SetDesignModeState(IDictionary)

(繼承來源 Control)
IControlDesignerAccessor.SetOwnerControl(Control)

如需這個成員的說明,請參閱 SetOwnerControl(Control)

(繼承來源 Control)
IControlDesignerAccessor.UserData

如需這個成員的說明,請參閱 UserData

(繼承來源 Control)
IDataBindingsAccessor.DataBindings

如需這個成員的說明,請參閱 DataBindings

(繼承來源 Control)
IDataBindingsAccessor.HasDataBindings

如需這個成員的說明,請參閱 HasDataBindings

(繼承來源 Control)
IExpressionsAccessor.Expressions

如需這個成員的說明,請參閱 Expressions

(繼承來源 Control)
IExpressionsAccessor.HasExpressions

如需這個成員的說明,請參閱 HasExpressions

(繼承來源 Control)
IParserAccessor.AddParsedSubObject(Object)

如需這個成員的說明,請參閱 AddParsedSubObject(Object)

(繼承來源 Control)
IPostBackEventHandler.RaisePostBackEvent(String)

實作 RaisePostBackEvent(String) 方法。

(繼承來源 ToolZone)

擴充方法

FindDataSourceControl(Control)

傳回與指定之控制項的資料控制項相關聯的資料來源。

FindFieldTemplate(Control, String)

傳回在指定之控制項的命名容器中所指定資料行的欄位樣板。

FindMetaTable(Control)

傳回包含資料控制項的中繼資料表物件。

GetDefaultValues(INamingContainer)

取得所指定資料控制項的預設值集合。

GetMetaTable(INamingContainer)

取得所指定資料控制項中的資料表中繼資料。

SetMetaTable(INamingContainer, MetaTable)

設定所指定資料控制項中的資料表中繼資料。

SetMetaTable(INamingContainer, MetaTable, IDictionary<String,Object>)

設定所指定資料控制項的資料表中繼資料及預設值對應。

SetMetaTable(INamingContainer, MetaTable, Object)

設定所指定資料控制項的資料表中繼資料及預設值對應。

TryGetMetaTable(INamingContainer, MetaTable)

判斷資料表中繼資料是否可供使用。

EnableDynamicData(INamingContainer, Type)

針對指定的資料控制項啟用動態資料行為。

EnableDynamicData(INamingContainer, Type, IDictionary<String,Object>)

針對指定的資料控制項啟用動態資料行為。

EnableDynamicData(INamingContainer, Type, Object)

針對指定的資料控制項啟用動態資料行為。

適用於

另請參閱