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
继承

示例

下面的代码示例演示如何在 Web 部件页上使用 ConnectionsZone 控件。 该示例包含四个部分:

  • 一个用户控件,可用于切换网页上的显示模式。

  • 一个源文件,其中包含邮政编码接口的代码,以及充当连接的提供程序和使用者的两 WebPart 个控件。

  • 一个网页,用于承载所有控件,演示如何声明 <asp:connectionszone> 元素,以及如何以声明方式和编程方式设置连接区域中的多个属性。

  • 说明该示例在浏览器中的工作原理。

此代码示例的第一部分是用户控件,使用户能够切换网页上的显示模式。 有关显示模式的详细信息和此控件中的源代码说明,请参阅 演练:更改 Web 部件页上的显示模式

<%@ 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 。 若要了解有关 Web 部件连接的详细信息,请参阅 WebPartConnectionConnectionPoint 类概述以及 Web 部件连接概述

如果存在形成 Web 部件连接所需的控件和条件,仍有必要实际连接控件。 可通过三种方式在服务器控件之间建立连接:在网页中声明连接、在代码中创建连接,或向页面添加控件 ConnectionsZone ,以便用户可以按需连接控件。 控件 ConnectionsZone 生成一个 UI,使用户能够连接或断开页面上满足建立连接所需条件的任何服务器控件。 它是一个可选控件,不需要建立连接,但在你想要让用户控制哪些服务器控件已连接或断开连接的情况下非常有用。

控件 ConnectionsZone 是从基类继承的 Web 部件工具区域控件之 ToolZone 一。 作为工具区域, ConnectionsZone 控件设计为仅在其网页处于特定显示模式时可见。 在这种情况下,当页面上的控件的DisplayMode属性值设置为ConnectDisplayMode) 时WebPartManager, (页面处于此模式时,显示模式称为连接模式。 在用户将页面切换到连接模式后,他们必须在其中一个服务器控件的谓词菜单上单击连接谓词,然后连接 UI 变为可见。

作为 Web 部件区域控件,控件 ConnectionsZone 是一种 WebZone 区域 (继承自 CompositeControl 设计为包含其他控件的类) 。 通常,区域 ConnectionsZone 具有与其他 Web 部件工具区域相同的大部分元素:页眉、正文或内容区域以及页脚。 有关 Web 部件区域以及区域的不同部分的完整讨论,请参阅 WebZone 类概述。

重要

与大多数其他 Web 部件区域不同,请务必注意,某个 ConnectionsZone 区域不包含与之关联的唯一类型的服务器控件。 有关区域及其包含的关联控件的列表,请参阅类概述中的 WebZone 图表。 ConnectionsZone但该区域不包含WebPartConnection控件。 相反,它提供一个 UI,让用户连接或断开页面上某个 WebPartZoneBase 区域中存在的服务器控件的用途非常有限。 控件中包含的唯一 ConnectionsZone 控件是标准 ASP.NET 服务器控件,该控件作为其 UI 的一部分生成,用于形成连接。

ConnectionsZone呈现控件时,它将基于页面上能够形成连接的服务器控件生成 UI。 控件 ConnectionsZone 确定页面上区域中的哪些服务器控件 WebPartZoneBase 是提供程序、哪些是使用者、哪些连接点可用,以及服务器控件当前是已连接还是已断开连接,然后相应地生成 UI。

例如,假设有一个 WebPart 控件能够成为提供程序,一个 WebPart 控件能够成为使用者,它们在页面上的 中 WebPartZone 声明,并且它们当前已断开连接。 当用户将页面切换为连接模式并单击其中一个控件上的连接谓词时,该 ConnectionsZone 控件将生成一个 UI,其中包含一个链接,单击该链接时,将显示一个窗体,用户可以在其中选择用于创建连接的选项。 (如果以前连接了控件,则初始视图会改为向用户显示一个按钮,用于断开控件) 的连接。 在用于创建新连接的连接 UI 中,向用户显示哪个控件是提供程序,哪个控件是使用者。 下拉列表控件显示在每个服务器控件的下方,其中列出了控件的可用 ConnectionPoint 对象。 从相应的下拉列表中,用户必须为提供程序选择一个 ProviderConnectionPoint 对象 (以确定将) 与使用者共享的接口和数据,每个使用者 (选择一个 ConsumerConnectionPoint 对象,以确定使用者将使用的接口和数据) 将连接到提供程序。

注意

在 Web 部件控件集默认实现中,一个提供程序可以连接到多个使用者,但一个使用者只能有一个提供程序。

若要使用 ConnectionsZone 控件,可以在网页上的 元素中 <form> 声明它 (,但不能嵌套在另一个 Web 部件区域元素) ,使用 <asp:connectionszone> 元素,也可以以编程方式将其添加到页面。 如果在页面中声明元素,与其他 Web 部件区域不同,则无法在元素的标记 <asp:connectionszone> 之间声明任何其他类型的服务器控件。 可以在其中声明与其自己的属性和样式详细信息相关的元素,但它是一个独立的元素,而不是可以在其中声明其他服务器控件的模板控件。

注意

为了提高辅助功能,控件 ConnectionsZone 在 元素中 <fieldset> 呈现。 元素 <fieldset> 对用于在控件中 ConnectionsZone 建立连接的相关控件集进行分组,并便于在可视用户代理 ((如普通 Web 浏览器) )和面向语音的用户代理 ((如屏幕阅读软件) )的控件之间进行选项卡式导航。

控件 ConnectionsZone 具有许多用于呈现连接 UI 的属性。 一组属性包括几个谓词(仅用于与连接相关),这些谓词在 UI 中执行操作: ConfigureVerbConnectVerbDisconnectVerb。 一组大型属性(特别是用于连接区域 UI)由显示在不同位置的文本字符串组成, (或在某些情况下,例如,在 UI 中) 发生错误时:、ConfigureConnectionTitleConnectToConsumerInstructionTextConnectToConsumerTextProvidersInstructionTextConnectToConsumerTitleExistingConnectionErrorMessageConsumersTitleGetFromTextConsumersInstructionTextGetTextConnectToProviderTitleInstructionTitleNewConnectionErrorMessageConnectToProviderTextConnectToProviderInstructionTextNoExistingConnectionTitleProvidersTitleNoExistingConnectionInstructionTextSendText和 。SendToTextConnectionsZone还包含许多在其他 Web 部件区域中找到的常见属性:CancelVerb、、CloseVerbDisplayEmptyZoneTextHeaderTextInstructionTextPartChromeType。 最后, WebPartToConnect 属性对于 类是唯一的,引用启动连接的控件 (这是用户在其谓词菜单中单击连接谓词的控件,这也是控件的属性) 中引用 WebPartManagerSelectedWebPart 控件。

ConnectionsZone 还具有许多方法,所有这些方法都是从基类继承和重写的,其中大多数方法都来自基本 Web 部件区域类。 有关详细信息,请参阅各个方法。

继承者说明

ConnectionsZone如果开发人员想要更改类的行为或它为使用连接提供的默认 UI,则可以扩展类。

构造函数

ConnectionsZone()

初始化 ConnectionsZone 类的新实例。

属性

AccessKey

获取或设置使您得以快速导航到 Web 服务器控件的访问键。

(继承自 WebControl)
Adapter

获取控件的浏览器特定适配器。

(继承自 Control)
AppRelativeTemplateSourceDirectory

获取或设置包含该控件的 PageUserControl 对象的应用程序相对虚拟目录。

(继承自 Control)
AssociatedDisplayModes

获取与特定 WebPartDisplayMode 区域关联的 ToolZone 对象的集合。

(继承自 ToolZone)
Attributes

获取与控件的特性不对应的任意特性(只用于呈现)的集合。

(继承自 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 标记的控件 ID。

(继承自 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

获取控件的事件处理程序委托列表。 此属性为只读。

(继承自 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

获取对页 UI 层次结构中服务器控件的父控件的引用。

(继承自 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

获取与区域中的 Web 部件控件关联的用户界面 (UI) 谓词的样式特性。

(继承自 WebZone)
ViewState

获取状态信息的字典,这些信息使您可以在同一页的多个请求间保存和还原服务器控件的视图状态。

(继承自 Control)
ViewStateIgnoresCase

获取一个值,该值指示 StateBag 对象是否不区分大小写。

(继承自 Control)
ViewStateMode

获取或设置此控件的视图状态模式。

(继承自 Control)
Visible

获取或设置一个值,该值指示服务器控件是否作为用户界面 (UI) 元素呈现在页上。

(继承自 ToolZone)
WebPartManager

获取对与 Web 部件页上的 WebPartManager 控件实例关联的 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)

使用指定的 idpathOffset 参数(该参数有助于搜索)中指定的整数在当前命名容器中搜索服务器控件。 不应重写此版本的 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。

(继承自 Control)
GetRouteUrl(String, RouteValueDictionary)

获取与一组路由参数以及某个路由名称对应的 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)

为指定数据控件启用动态数据行为。

适用于

另请参阅