WebPartManager 类

定义

用作 Web 部件控件集的中心类,管理所有的 Web 部件控件、功能和网页上发生的事件。Serves as the central class of the Web Parts control set, managing all the Web Parts controls, functionality, and events that occur on a Web page.

public ref class WebPartManager : System::Web::UI::Control, System::Web::UI::INamingContainer, System::Web::UI::WebControls::WebParts::IPersonalizable
[System.ComponentModel.Bindable(false)]
public class WebPartManager : System.Web.UI.Control, System.Web.UI.INamingContainer, System.Web.UI.WebControls.WebParts.IPersonalizable
type WebPartManager = class
    inherit Control
    interface INamingContainer
    interface IPersonalizable
Public Class WebPartManager
Inherits Control
Implements INamingContainer, IPersonalizable
继承
WebPartManager
属性
实现

示例

下面的代码示例演示了WebPartManager控件的声明性和编程式使用。The following code example demonstrates both declarative and programmatic use of the WebPartManager control.

此代码示例包含四个部分:The code example has four parts:

  • 使您能够在 Web 部件页上更改显示模式的用户控件。A user control that enables you to change display modes on a Web Parts page.

  • 一个网页,其中包含两个WebPart可以连接的自定义控件和一个<asp:webpartmanager>元素。A Web page that contains two custom WebPart controls that can be connected, and an <asp:webpartmanager> element.

  • 包含两个自定义WebPart控件和自定义接口的源代码文件。A source code file that contains two custom WebPart controls, and a custom interface.

  • 说明如何在浏览器中工作。An explanation of how the example works in a browser.

用户控件具有一个下拉列表控件,该控件在给定页面上存在的 Web 部件控件的情况下,显示页面上可能的显示模式。The user control has a drop-down list control that shows the possible display modes on a page, given the Web Parts controls that are present on the page. 在此代码示例的网页中,此用户控件刚好在页面标记中的WebPartManager元素下方声明,并在网页顶部附近有一个Register指令来注册控件。In the Web page for this code example, this user control is declared just below the WebPartManager element in the page's markup, and there is a Register directive near the top of the Web page to register the control. 有关显示模式的详细信息以及此控件中源代码的说明,请参阅演练:更改 Web 部件页上的显示模式。For details about display modes and a description of the source code in this control, see Walkthrough: Changing Display Modes on a Web Parts Page.

<%@ 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="&nbsp;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="&nbsp;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>

网页的声明性标记包含Register用户控件和自定义控件的指令。The declarative markup for the Web page contains Register directives for both the user control and the custom controls. 有一个<asp:webpartmanager>元素、一个<asp:webpartzone>元素包含自定义控件和一个<asp:connectionszone>元素。There is an <asp:webpartmanager> element, an <asp:webpartzone> element to contain the custom controls, and an <asp:connectionszone> element. 该页还包含一些用于处理WebPartManager控件的与连接相关的事件的内联代码; 你可以在连接和断开连接控件时查看此代码的效果。The page also contains some inline code that handles connection-related events for the WebPartManager control; you can see the effect of this code as you connect and disconnect controls.

<%@ Page Language="C#" %>
<%@ register TagPrefix="uc1" 
  TagName="DisplayModeMenuCS" 
  Src="DisplayModeMenuCS.ascx" %>
<%@ register tagprefix="aspSample" 
  Namespace="Samples.AspNet.CS.Controls" 
  Assembly="ConnectionSampleCS" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
 
  private void UpdateLabelData(int wpCount, int connCount)
  {
    Label1.Text = "WebPart Control Count:  " + wpCount.ToString();
    Label2.Text = "Connections Count: " + connCount.ToString();
  }

  protected void WebPartManager1_WebPartsConnected(object sender, WebPartConnectionsEventArgs e)
  {
    UpdateLabelData(WebPartManager1.WebParts.Count,
      WebPartManager1.Connections.Count);
  }

  protected void WebPartManager1_WebPartsDisconnected(object sender, WebPartConnectionsEventArgs e)
  {
    UpdateLabelData(WebPartManager1.WebParts.Count,
      WebPartManager1.Connections.Count);
  }
  
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
      <!-- Reference the WebPartManager control. -->
      <asp:WebPartManager ID="WebPartManager1" runat="server"  
        OnWebPartsConnected="WebPartManager1_WebPartsConnected" 
        OnWebPartsDisconnected="WebPartManager1_WebPartsDisconnected" />
    <div>
      <uc1:DisplayModeMenuCS ID="displaymode1" runat="server" />
      <!-- Reference consumer and provider controls in a zone. -->
      <asp:WebPartZone ID="WebPartZone1" runat="server">
        <ZoneTemplate>
          <aspSample:ZipCodeWebPart ID="zip1" 
            runat="server" 
            Title="Zip Code Control"/>
          <aspSample:WeatherWebPart ID="weather1" 
            runat="server" 
            Title="Weather Control" />
        </ZoneTemplate>
      </asp:WebPartZone>
      <hr />
      <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
      <br />
      <asp:Label ID="Label2" runat="server" Text=""></asp:Label>
      <!-- Add a ConnectionsZone so users can connect controls. -->
      <asp:ConnectionsZone ID="ConnectionsZone1" runat="server" />
    </div>
    </form>
</body>
</html>
<%@ Page Language="vb" %>
<%@ register TagPrefix="uc1" 
  TagName="DisplayModeMenuVB" 
  Src="DisplayModeMenuVB.ascx" %>
<%@ register tagprefix="aspSample" 
  Namespace="Samples.AspNet.VB.Controls" 
  Assembly="ConnectionSampleVB" %>

<!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 WebPartManager1_WebPartsConnected( _
    ByVal sender As Object, _
    ByVal e As System.Web.UI.WebControls.WebParts.WebPartConnectionsEventArgs)
    
    UpdateLabelData(WebPartManager1.WebParts.Count, _
      WebPartManager1.Connections.Count)
    
  End Sub

  Protected Sub WebPartManager1_WebPartsDisconnected( _
    ByVal sender As Object, _
    ByVal e As System.Web.UI.WebControls.WebParts.WebPartConnectionsEventArgs)
    
    UpdateLabelData(WebPartManager1.WebParts.Count, _
      WebPartManager1.Connections.Count)
    
  End Sub
  
  Private Sub UpdateLabelData(ByVal wpCount As Integer, _
    ByVal connCount As Integer)
    
    Label1.Text = "WebPart Control Count:  " & wpCount.ToString()
    Label2.Text = "Connections Count: " & connCount.ToString()
    
  End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>ASP.NET Example</title>
</head>
<body>
    <form id="form1" runat="server">
      <!-- Reference the WebPartManager control. -->
      <asp:WebPartManager ID="WebPartManager1" runat="server" OnWebPartsConnected="WebPartManager1_WebPartsConnected" OnWebPartsDisconnected="WebPartManager1_WebPartsDisconnected" />
    <div>
      <uc1:DisplayModeMenuVB ID="displaymode1" runat="server" />
      <!-- Reference consumer and provider controls in a zone. -->
      <asp:WebPartZone ID="WebPartZone1" runat="server">
        <ZoneTemplate>
          <aspSample:ZipCodeWebPart ID="zip1" 
            runat="server" 
            Title="Zip Code Control"/>
          <aspSample:WeatherWebPart ID="weather1" 
            runat="server" 
            Title="Weather Control" />
        </ZoneTemplate>
      </asp:WebPartZone>
      <hr />
      <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
      <br />
      <asp:Label ID="Label2" runat="server" Text=""></asp:Label>
      <!-- Add a ConnectionsZone so users can connect controls. -->
      <asp:ConnectionsZone ID="ConnectionsZone1" runat="server" />
    </div>
    </form>
</body>
</html>

该示例的第三部分是控件的源代码。The third part of the example is the source code for the controls. 请注意,有一个名为IZipCode的接口,此接口是ZipCodeWebPart在类中实现的。Note that there is an interface named IZipCode, and this interface is implemented in the ZipCodeWebPart class. 此类具有一个名ProvideIZipCode为的特殊回调方法,用作提供程序。This class has a special callback method named ProvideIZipCode that serves as a provider. 另一种名WeatherWebPart为的类型也是使用名为GetIZipCode的特殊方法实现的,该方法使控件可以作为另一个控件的使用者。The other type, named WeatherWebPart, is also implemented with a special method named GetIZipCode, which enables the control to act as a consumer of the other control.

要使代码示例运行,必须编译此源代码。For the code example to run, you must compile this source code. 可以显式编译该程序集,并将生成的程序集放在网站的 Bin 文件夹或全局程序集缓存中。You can compile it explicitly and put the resulting assembly in your Web site's Bin folder or the global assembly cache. 或者,你可以将源代码放在站点的 App_Code 文件夹中,在此文件夹中,它将在运行时动态编译。Alternatively, you can put the source code in your site's App_Code folder, where it will be dynamically compiled at run time. 此代码示例假定已将源编译为程序集,网页中的Register指令引用程序集名称。This code example assumes that you have compiled the source into an assembly, and the Register directive in the Web page references the assembly name. 有关演示如何编译的演练,请参阅演练:开发和使用自定义 Web 服务器控件For a walkthrough that demonstrates how to compile, see Walkthrough: Developing and Using a Custom Web Server Control.

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")]
    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")]
    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")> _
    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")> _
    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

在浏览器中加载网页后,请单击 "显示模式" 下拉列表控件,然后选择 "连接",将页面切换到连接模式。After you have loaded the Web page in a browser, click the Display Mode drop-down list control and select Connect to switch the page to connect mode. 连接模式使用<asp:connectionszone>元素使您能够在控件之间创建连接。Connect mode uses the <asp:connectionszone> element to enable you to create connections between controls. 在连接模式下,单击邮政编码控件标题栏中的向下箭头以激活其谓词菜单,然后单击 "连接"。In connect mode, click the downward arrow in the title bar of the ZIP Code control to activate its verbs menu, and then click Connect. 显示连接 UI 后,单击 "创建使用者的连接" 链接。After the connection UI appears, click the Create a connection to a Consumer link. 出现包含下拉列表控件的单元格。A cell appears that has a drop-down list control. 在下拉列表中选择 "天气控制",然后单击 "连接" 以完成两个控件的连接。Select Weather Control in the drop-down list, and then click Connect to complete the connection of the two controls. 单击 "关闭",然后使用 "显示模式" 下拉列表将页面恢复到正常浏览模式。Click Close, and then use the Display Mode drop-down list to return the page to normal browse mode. 您可以输入邮政编码,并使用您输入的值更新使用者控件。You can enter a ZIP Code, and the consumer control will be updated with the value you enter. 由于该Personalizable属性在源代码中标记有特性,因此此属性值将在浏览器会话中保持不变,从而保存用户输入的值。 ZipCodeBecause the ZipCode property was marked with the Personalizable attribute in the source code, this property value will persist across browser sessions, thus saving the value entered by a user. 更复杂的使用者控件可以采用邮政编码信息,根据代码查找天气信息,并将其显示给用户。A more sophisticated consumer control could take the ZIP code information, look up weather information based on the code, and display it to a user.

注解

WebPartManager控件充当 Web 部件应用程序的中心或控制中心。The WebPartManager control acts as the hub or control center of a Web Parts application. 在使用 Web 部件控件的每一页上都必须WebPartManager有一个(且仅有一个)控件实例。There must be one--and only one--WebPartManager control instance on every page that uses Web Parts controls. 与 Web 部件应用程序的大多数方面一样, WebPartManager控件仅适用于经过身份验证的用户。As with most aspects of Web Parts applications, the WebPartManager control works only with authenticated users. 此外,其功能几乎完全适用于驻留在继承自WebZone类 Web 部件区域中的服务器控件。Further, its functionality works almost entirely with server controls that reside within Web Parts zones that inherit from the WebZone class. 驻留在这些区域之外的页上的服务器控件的 Web 部件功能或与WebPartManager控件的交互可能非常小。Server controls that reside on a page outside of these zones can have very little Web Parts functionality or interaction with the WebPartManager control.

作为页面上 Web 部件功能的中心, WebPartManager控件执行下表中所述的任务类型。As the hub for Web Parts functionality on a page, the WebPartManager control carries out the kinds of tasks described in the following table.

任务类别Task category 控件的作用What the control does
跟踪 Web 部件控件Tracking Web Parts controls 跟踪页面上许多不同类型的控件,这些控件提供 Web 部件功能,包括WebPart控件、连接、区域等。Keeps track of the many different kinds of controls on a page that provide Web Parts features, including WebPart controls, connections, zones, and others.
添加和删除 Web 部件控件Adding and removing Web Parts controls 提供用于在页上添加、删除和关闭WebPart控件的方法。Provides the methods for adding, deleting, and closing WebPart controls on a page.
管理连接Administering connections 在控件之间创建连接,并监视连接以及添加和删除这些连接的过程。Creates connections between controls, and monitors the connections as well as the processes of adding and removing them.
个性化控件和页面Personalizing controls and pages 使用户能够将控件移动到页面上的不同位置,并启动用户可以在其中编辑控件外观、属性和行为的视图。Enables users to move controls to different locations on a page, and launches the views in which users can edit the appearance, properties, and behavior of controls. 维护每个页面上的特定于用户的个性化设置。Maintains user-specific personalization settings on each page.
在不同的页面视图之间切换Toggling between different page views 在页面的不同专用视图之间切换页面,以便用户可以执行某些任务,如更改页面布局或编辑控件。Switches a page among different specialized views of the page, so that users can carry out certain tasks such as changing page layout or editing controls.
引发 Web 部件生命周期事件Raising Web Parts life-cycle events 定义、引发并使开发人员能够处理 Web 部件控件的生命周期事件,例如,在添加、移动、连接或删除控件时。Defines, raises, and enables developers to handle life-cycle events of Web Parts controls, such as when controls are being added, moved, connected, or deleted.
启用控件的导入和导出Enabling import and export of controls 导出包含WebPart控件属性状态的 XML 流,并允许用户导入文件,以便于在其他页面或站点中个性化复杂控件。Exports XML streams that contain the state of the properties of WebPart controls, and allows users to import the files for convenience in personalizing complex controls in other pages or sites.

WebPartManager类具有一组大的属性。The WebPartManager class has a large set of properties. 与跟踪其他WebPartManager控件的角色一致,它具有多个属性,这些属性可引用 Web 部件控件或其他特殊 Web 部件对象的集合。Consistent with the WebPartManager role of tracking other controls, it has a number of properties that reference collections of either Web Parts controls, or other special Web Parts objects. AvailableTransformers、 、、、DisplayModes、 、和Zones属性都WebPartManager是控件用来进行跟踪的所有集合SupportedDisplayModes DynamicConnections Connections Controls WebParts管理任务。The AvailableTransformers, Connections, Controls, DisplayModes, DynamicConnections, SupportedDisplayModes, WebParts, and Zones properties are all collections used by the WebPartManager control for its tracking and other management tasks.

另一组属性包含可自定义的警告,这些警告适用于在 Web 部件应用程序中出现的某些方案。Another group of properties contains customizable warnings that apply in certain scenarios that occur in a Web Parts application. 其中包括CloseProviderWarning DeleteWarning、、和ExportSensitiveDataWarning属性。These include the CloseProviderWarning, the DeleteWarning, and the ExportSensitiveDataWarning properties.

WebPartManager类将重写它的一些基继承属性,这些属性由许多 Web 服务器控件使用。The WebPartManager class overrides some of its base inherited properties, which are used by many Web server controls. 其中包括EnableThemingSkinIDVisible属性。These include the EnableTheming, SkinID, and Visible properties.

最后,有一组属性可用于访问应用程序的当前状态。Finally, there is a group of properties useful for accessing the current state of the application. DisplayMode属性指示页面所在的当前显示模式。The DisplayMode property indicates the current display mode that a page is in. EnableClientScript属性指示是否允许控件呈现客户端脚本,这在以下情况下适用:用户可能具有具有不同功能的浏览器或已关闭脚本。The EnableClientScript property indicates whether a control is allowed to render client-side script, which is relevant in situations where users might have browsers with different capabilities or have scripting turned off. Internals属性用于引用包含对扩展性事例使用的大量重要 Web 部件方法的调用的实用工具类。The Internals property is useful for referencing a utility class that contains the calls to a number of important Web Parts methods that are used for extensibility cases. 通过在单独的类( WebPartManagerInternals类)中隐藏对这些方法的调用WebPartManager ,可简化类的 API。By hiding the calls to these methods in a separate class (the WebPartManagerInternals class), the WebPartManager class's own API is simplified. Personalization属性提供对存储用户个性化设置并将该数据保存到永久存储的个性化对象的访问。The Personalization property provides access to the personalization objects that store users' personalization settings and persist that data to permanent storage. 属性指示用户或应用程序当前选择的页上的控件。WebPart SelectedWebPartThe SelectedWebPart property indicates which WebPart control on a page is currently selected by the user or the application. 属性指示WebPart控件上的自定义个性化设置数据是否已更改。 IPersonalizable.IsDirtyThe IPersonalizable.IsDirty property indicates whether custom personalization data on a WebPart control has changed.

WebPartManager控件包含五种内置显示模式或网页视图。The WebPartManager control contains five built-in display modes, or views of a Web page. 开发人员可以扩展此功能,通过扩展WebZoneToolZone或类等类型来创建自定义显示模式。Developers can extend this feature, creating custom display modes by extending types such as the WebZone class or the ToolZone class. 如果页面上存在对应于给定显示模式的适当类型的控件,则用户可以将页面切换到各种显示模式。Users can switch a page into the various display modes, provided that the proper kind of controls that correspond to a given display mode are present on a page.

备注

可以扩展此功能,以便用户可以切换到自定义显示模式,而无需在页面上放置相应的区域。It is possible to extend this feature so that users can switch into a custom display mode without having a corresponding zone on the page. 但是,默认行为是显示模式与区域相对应。However, the default behavior is that display modes correspond to zones.

标准显示模式由WebPartManager类中的公共字段表示。The standard display modes are represented by public fields in the WebPartManager class. 下表汇总了字段及其引用的显示模式。The following table summarizes the fields and the display modes they refer to. 正如前文所述,页面的当前显示模式始终在DisplayMode属性中引用,在特定页面上可能出现的显示模式集(给定页面上存在的区域类型)包含SupportedDisplayModes在属性中。The current display mode of a page, as noted above, is always referenced in the DisplayMode property, and the set of display modes that is possible on a particular page, given the kind of zones that are present on the page, is contained in the SupportedDisplayModes property.

字段Field 显示模式详细信息Display mode details
BrowseDisplayMode 网页的普通用户视图;默认和最常见的显示模式。The normal user view of a Web page; the default and most common display mode.
DesignDisplayMode 用户可以重新排列或删除控件以更改页面布局的视图。The view in which users can rearrange or delete controls to change the page layout.
EditDisplayMode 编辑用户界面(UI)变为可见的视图;用户可以编辑在正常浏览模式下可见控件的外观、属性和行为。The view in which an editing user interface (UI) becomes visible; users can edit the appearance, properties, and behavior of the controls that are visible in the normal browse mode.
CatalogDisplayMode 目录 UI 变为可见的视图;用户可以将控件从可用控件的目录添加到页面。The view in which a catalog UI becomes visible; users can add controls to a page from catalogs of available controls.
ConnectDisplayMode 连接 UI 将在其中可见的视图;用户可以连接、管理或断开控件之间的连接。The view in which a connection UI becomes visible; users can connect, manage, or disconnect connections between controls.

WebPartManager控件还包含大量事件,这些事件在 Web 部件页面和控件的生命周期内非常重要。The WebPartManager control also contains a number of events that are critical in the life cycle of Web Parts pages and controls. 这些事件提供对 Web 部件控件的行为的精确编程控制。These events provide precise programmatic control over the behavior of Web Parts controls. 大多数方法直接与WebPart控件(或放置在区域中WebPartZoneBase的其他服务器或用户控件)相关,以便它们能够作为WebPart控件。Most methods pertain directly to WebPart controls (or other server or user controls that are placed in WebPartZoneBase zones so that they can behave as WebPart controls). 但有些事件涉及页面的状态或页面上的连接。However, a few events pertain to the state of the page or connections on the page. 下表列出了可用的事件并汇总了其用途。The following table lists the available events and summarizes their purposes.

备注

在下表中的所有情况下,"控件" 一WebPart词是指位于区域中的控件或任何服务器控件,并在运行时GenericWebPart使用对象进行包装。In all cases in the following table, the word "control" refers to a WebPart control or any server control that resides in a zone and is wrapped with a GenericWebPart object at run time.

事件Event 说明Description
AuthorizeWebPart 恰好在将控件添加到页面之前发生,以验证它是否已获授权。Occurs just before a control is added to a page to verify that it is authorized.
ConnectionsActivated 在页面上的所有连接都已激活之后发生。Occurs after all the connections on a page have been activated.
ConnectionsActivating 恰好在激活页上的所有连接的过程之前发生。Occurs just before the process of activating all the connections on a page.
DisplayModeChanged 在页的当前显示模式更改之后发生。Occurs after the current display mode of a page has changed.
DisplayModeChanging 恰好在更改页的显示模式的过程之前发生。Occurs just before the process of changing a page's display mode.
SelectedWebPartChanged 在取消选定控件后发生。Occurs after the selection of a control has been canceled.
SelectedWebPartChanging 恰好在取消选择控件之前发生。Occurs just before the process of canceling the selection of a control.
WebPartAdded 在将控件添加到区域之后发生。Occurs after a control has been added to a zone.
WebPartAdding 恰好在将控件添加到区域的过程之前发生。Occurs just before the process of adding a control to a zone.
WebPartClosed 在控件关闭(从页中移除)后发生。Occurs after a control has been closed (removed from a page).
WebPartClosing 恰好在关闭控件的进程之前发生。Occurs just before the process of closing a control.
WebPartDeleted 在永久删除动态控件(以编程方式创建或从目录中添加的控件)的实例之后发生。Occurs after an instance of a dynamic control (one that was created programmatically or added from a catalog) has been permanently deleted.
WebPartDeleting 恰好在删除动态控件的过程之前发生。Occurs just before the process of deleting a dynamic control.
WebPartMoved 控件在其区域内移动或移动到另一个区域后发生。Occurs after a control has moved within its zone or to another zone.
WebPartMoving 恰好在移动控件的进程之前发生。Occurs just before the process of moving a control.
WebPartsConnected 在为连接选择的两个控件已建立连接之后发生。Occurs after two controls selected for participation in a connection have established the connection.
WebPartsConnecting 恰好在连接两个控件的过程之前发生。Occurs just before the process of connecting two controls.
WebPartsDisconnected 在两个连接的控件断开连接之后发生。Occurs after two connected controls have been disconnected.
WebPartsDisconnecting 恰好在断开两个控件的连接过程之前发生。Occurs just before the process of disconnecting two controls.

WebPartManager控件具有大量用于管理 Web 部件页面的方法。The WebPartManager control has numerous methods for managing Web Parts pages. 此处未列出的一大组方法是其名称采用的形式为 On事件名称的方法。A large set of the methods, not listed here, are methods whose names take the form of OnEventName. 这些方法通常会引发相关事件,并为事件提供类型WebPartEventHandler的处理程序。These methods typically raise their associated event, and provide the event with a handler of type WebPartEventHandler. 这些方法中的大多数可由继承自WebPartManager类的开发人员重写。Most of these methods can be overridden by developers who inherit from the WebPartManager class. 此外,页开发人员还可以为与这些方法关联的事件提供自定义处理程序。Also, page developers can provide custom handlers for the events associated with these methods. 例如,在WebPartAdded发生事件的情况下,页面开发人员可以OnWebPartAdded将属性添加到网页标记<asp:webpartmanager>中的元素,然后将自定义方法名称分配给该属性,以便为事件提供自定义处理。For example, in the case of the WebPartAdded event, a page developer could add an OnWebPartAdded attribute to the <asp:webpartmanager> element in the markup of a Web page, and then assign a custom method name to the attribute to provide custom handling for the event. 特性对应OnWebPartAdded于方法,而事件处理的基本模式适用于大多数 Web 部件事件及其关联方法。The attribute corresponds to the OnWebPartAdded method, and this basic pattern of event handling works for most Web Parts events and their associated methods.

此外,该WebPartManager控件具有特定于管理WebPart控件(和用作WebPart控件的服务器控件或用户控件)的任务的方法。In addition, the WebPartManager control has methods particular to the task of managing WebPart controls (and server or user controls used as WebPart controls). 这些方法包括AddWebPartAuthorizeWebPartCloseWebPartCopyWebPart、 、、DeleteWebPartBeginWebPartEditing 、、EndWebPartEditing、 、、ExportWebPart CreateWebPart DisconnectWebPart GetGenericWebPart ImportWebPart IsAuthorized、和MoveWebPartThese methods include AddWebPart, AuthorizeWebPart, CloseWebPart, CopyWebPart, CreateWebPart, DeleteWebPart, DisconnectWebPart, BeginWebPartEditing, EndWebPartEditing, ExportWebPart, GetGenericWebPart, ImportWebPart, IsAuthorized, and MoveWebPart.

另一组方法专用于连接。Another set of methods is specialized for connections. 其中ActivateConnections包括、CreateAvailableTransformers 、、GetProviderConnectionPoints、、 、、DisconnectWebParts、和等方法。 DisconnectWebPart ConnectWebParts BeginWebPartConnecting CanConnectWebParts EndWebPartConnecting GetConsumerConnectionPointsThis includes methods such as ActivateConnections, BeginWebPartConnecting, CanConnectWebParts, ConnectWebParts, CreateAvailableTransformers, DisconnectWebPart, DisconnectWebParts, EndWebPartConnecting, GetConsumerConnectionPoints, and GetProviderConnectionPoints.

最后,一些WebPartManager方法侧重于个性化设置功能。Finally, some WebPartManager methods focus on personalization functionality. 它们包括 CreatePersonalizationLoadControlStateSaveCustomPersonalizationStateSetPersonalizationDirtyIPersonalizable.LoadIPersonalizable.SaveSaveControlStateThese include CreatePersonalization, LoadControlState, SaveCustomPersonalizationState, SetPersonalizationDirty, IPersonalizable.Load, IPersonalizable.Save, and SaveControlState.

有关可WebPartManager Internals通过属性访问的其他方法的详细信息, WebPartManagerInternals请参阅类的文档。For more information on other WebPartManager methods that are accessible through the Internals property, see the documentation for the WebPartManagerInternals class.

继承者说明

WebPartManager控件设计为扩展。The WebPartManager control is designed to be extended. 由于这是 Web 部件应用程序的核心,因此当你想要在 Web 部件控件集中扩展某些特定类型或控件时,在许多情况下,你还WebPartManager必须扩展类,因为它可能有一些需要进行的属性或方法 自定义类型在 Web 部件应用程序的上下文中工作。Because it is so central to Web Parts applications, when you want to extend some specific type or control in the Web Parts control set, in many cases you must also extend the WebPartManager class, because it is likely to have some property or method that is required to make your custom type work in the context of a Web Parts application. Web 部件引用文档(请参阅System.Web.UI.WebControls.WebParts),讨论如何扩展 Web 部件类型时,通常会提到还需要执行哪些操作来WebPartManager扩展类,或者在代码示例中演示如何对其进行扩展。The Web Parts reference documentation (see System.Web.UI.WebControls.WebParts), when discussing how to extend a Web Parts type, frequently mentions what needs to be done to extend the WebPartManager class as well, or shows how to extend it in a code example.

构造函数

WebPartManager()

初始化 WebPartManager 类的新实例。Initializes a new instance of the WebPartManager class.

字段

BrowseDisplayMode

表示包含 Web 部件控件的页的默认显示模式。Represents the default display mode for pages that contain Web Parts controls. 此字段为只读。This field is read-only.

CatalogDisplayMode

表示用于从控件目录向网页添加服务器控件的显示模式。Represents the display mode used for adding server controls from a catalog of controls to a Web page. 此字段为只读。This field is read-only.

ConnectDisplayMode

表示用于显示特殊用户界面 (UI) 以便用户管理 WebPart 控件之间的连接的显示模式。Represents the display mode used for displaying a special user interface (UI) for users to manage connections between WebPart controls. 此字段为只读。This field is read-only.

DesignDisplayMode

表示用于更改包含 Web 部件控件的网页布局的显示模式。Represents the display mode used for changing the layout of Web pages that contain Web Parts controls. 此字段为只读。This field is read-only.

EditDisplayMode

表示最终用户可在其中编辑和修改服务器控件的显示模式。Represents the display mode in which end users can edit and modify server controls. 此字段为只读。This field is read-only.

属性

Adapter

获取控件的浏览器特定适配器。Gets the browser-specific adapter for the control.

(继承自 Control)
AppRelativeTemplateSourceDirectory

获取或设置包含该控件的 PageUserControl 对象的应用程序相对虚拟目录。Gets or sets the application-relative virtual directory of the Page or UserControl object that contains this control.

(继承自 Control)
AvailableTransformers

获取 WebPartTransformer 对象的集合,这些对象可用于在服务器控件之间创建 Web 部件连接。Gets a collection of WebPartTransformer objects that are available for use in creating Web Parts connections between server controls.

BindingContainer

获取包含该控件的数据绑定的控件。Gets the control that contains this control's data binding.

(继承自 Control)
ChildControlsCreated

获取一个值,该值指示是否已创建服务器控件的子控件。Gets a value that indicates whether the server control's child controls have been created.

(继承自 Control)
ClientID

获取由 ASP.NET 生成的 HTML 标记的控件 ID。Gets the control ID for HTML markup that is generated by ASP.NET.

(继承自 Control)
ClientIDMode

获取或设置用于生成 ClientID 属性值的算法。Gets or sets the algorithm that is used to generate the value of the ClientID property.

(继承自 Control)
ClientIDSeparator

获取一个字符值,该值表示 ClientID 属性中使用的分隔符字符。Gets a character value representing the separator character used in the ClientID property.

(继承自 Control)
CloseProviderWarning

获取或设置一个警告,用户关闭在连接中充当其他控件的提供者的控件时,会显示该警告。Gets or sets a warning that is displayed when a user closes a control that is acting as a provider to other controls in a connection.

Connections

获取对网页上所有当前连接的集合的引用。Gets a reference to the collection of all current connections on a Web page.

Context

为当前 Web 请求获取与服务器控件关联的 HttpContext 对象。Gets the HttpContext object associated with the server control for the current Web request.

(继承自 Control)
Controls

获取包含在网页的 WebPart 区域中并由 WebPartZoneBase 控件管理的所有 WebPartManager、服务器或用户控件的集合。Gets the collection of all WebPart, server, or user controls that are contained in WebPartZoneBase zones on a Web page and are managed by the WebPartManager control.

DataItemContainer

如果命名容器实现 IDataItemContainer,则获取对命名容器的引用。Gets a reference to the naming container if the naming container implements IDataItemContainer.

(继承自 Control)
DataKeysContainer

如果命名容器实现 IDataKeysControl,则获取对命名容器的引用。Gets a reference to the naming container if the naming container implements IDataKeysControl.

(继承自 Control)
DeleteWarning

获取或设置一个自定义警告消息,当最终用户删除一个控件时,将显示该消息。Gets or sets a custom warning message displayed to end users when they delete a control.

DesignMode

获取一个值,该值指示是否正在使用设计图面上的一个控件。Gets a value indicating whether a control is being used on a design surface.

(继承自 Control)
DisplayMode

获取或设置包含 Web 部件控件的网页的活动显示模式。Gets or sets the active display mode for a Web page that contains Web Parts controls.

DisplayModes

获取与 WebPartManager 控件关联的所有显示模式的只读集合。Gets a read-only collection of all display modes that are associated with a WebPartManager control.

DynamicConnections

获取网页上当前存在的所有动态连接的集合。Gets the collection of all dynamic connections that currently exist on a Web page.

EnableClientScript

获取或设置一个值,该值确定在包含 WebPartManager 控件的网页上是否启用了客户端脚本。Gets or sets a value that determines whether client-side scripting is enabled on the Web page that contains a WebPartManager control.

EnableTheming

获取一个值,该值指示网页启用了主题。Gets a value indicating that the use of themes is enabled on a Web page.

EnableViewState

获取或设置一个值,该值指示服务器控件是否向发出请求的客户端保持自己的视图状态以及它所包含的任何子控件的视图状态。Gets or sets a value indicating whether the server control persists its view state, and the view state of any child controls it contains, to the requesting client.

(继承自 Control)
Events

获取控件的事件处理程序委托列表。Gets a list of event handler delegates for the control. 此属性是只读的。This property is read-only.

(继承自 Control)
ExportSensitiveDataWarning

获取或设置在用户尝试从 WebPart 控件导出敏感状态数据时显示的警告消息的文本。Gets or sets the text of a warning message that is displayed when a user attempts to export sensitive state data from a WebPart control.

HasChildViewState

获取一个值,该值指示当前服务器控件的子控件是否具有任何已保存的视图状态设置。Gets a value indicating whether the current server control's child controls have any saved view-state settings.

(继承自 Control)
ID

获取或设置分配给服务器控件的编程标识符。Gets or sets the programmatic identifier assigned to the server control.

(继承自 Control)
IdSeparator

获取用于分隔控件标识符的字符。Gets the character used to separate control identifiers.

(继承自 Control)
Internals

获取对 WebPartManagerInternals 类的引用,该类用于合并和拆分实际在 WebPartManager 类中实现的,但通常对控件开发人员很有用的一组方法。Gets a reference to the WebPartManagerInternals class, which is used to combine and separate a set of methods that are actually implemented in the WebPartManager class, but are mostly useful for control developers.

IsChildControlStateCleared

获取一个值,该值指示该控件中包含的控件是否具有控件状态。Gets a value indicating whether controls contained within this control have control state.

(继承自 Control)
IsCustomPersonalizationStateDirty

获取一个值,该值指示是否已进行了个性化设置更改,这些更改影响 WebPartManager 控件所控制的页级别个性化设置详细信息。Gets a value that indicates whether personalization changes have been made that affect page-level personalization details controlled by the WebPartManager control.

IsTrackingViewState

获取一个值,用于指示服务器控件是否会将更改保存到其视图状态中。Gets a value that indicates whether the server control is saving changes to its view state.

(继承自 Control)
IsViewStateEnabled

获取一个值,该值指示是否为该控件启用了视图状态。Gets a value indicating whether view state is enabled for this control.

(继承自 Control)
LoadViewStateByID

获取一个值,该值指示控件是否通过 ID 而不是索引参与加载其视图状态。Gets a value indicating whether the control participates in loading its view state by ID instead of index.

(继承自 Control)
MediumPermissionSet

获取仅允许 PermissionSet 权限和 Execution 权限的 Medium 对象。Gets a PermissionSet object that allows only Execution permission and Medium permission.

MinimalPermissionSet

获取仅允许 PermissionSet 权限和 Execution 权限的 Minimal 对象。Gets a PermissionSet object that allows only Execution permission and Minimal permission.

NamingContainer

获取对服务器控件的命名容器的引用,此引用创建唯一的命名空间,以区分具有相同 ID 属性值的服务器控件。Gets a reference to the server control's naming container, which creates a unique namespace for differentiating between server controls with the same ID property value.

(继承自 Control)
Page

获取对包含服务器控件的 Page 实例的引用。Gets a reference to the Page instance that contains the server control.

(继承自 Control)
Parent

获取对页 UI 层次结构中服务器控件的父控件的引用。Gets a reference to the server control's parent control in the page control hierarchy.

(继承自 Control)
Personalization

获取对包含网页个性化设置数据的对象的引用。Gets a reference to an object that contains personalization data for a Web page.

RenderingCompatibility

获取一个值,该值指定呈现的 HTML 将与之兼容的 ASP.NET 版本。Gets a value that specifies the ASP.NET version that rendered HTML will be compatible with.

(继承自 Control)
SelectedWebPart

获取对当前选择的用于编辑或用于创建与另一个控件的连接的 WebPart 或其他服务器控件的引用。Gets a reference to a WebPart or other server control that is currently selected for editing or for creating a connection with another control.

Site

获取容器信息,该容器在呈现于设计图面上时承载当前控件。Gets information about the container that hosts the current control when rendered on a design surface.

(继承自 Control)
SkinID

获取或设置一个空字符串 (""),使 WebPartManager 控件不能应用任何外观。Gets or sets an empty string ("") so that no skin can be applied to the WebPartManager control.

StaticConnections

获取对网页上所有定义为静态连接的 WebPartConnection 对象的集合的引用。Gets a reference to the collection of all WebPartConnection objects on a Web page that are defined as static connections.

SupportedDisplayModes

获取特定网页上所有可用显示模式的只读集合。Gets a read-only collection of all display modes that are available on a particular Web page.

TemplateControl

获取或设置对包含该控件的模板的引用。Gets or sets a reference to the template that contains this control.

(继承自 Control)
TemplateSourceDirectory

获取包含当前服务器控件的 PageUserControl 的虚拟目录。Gets the virtual directory of the Page or UserControl that contains the current server control.

(继承自 Control)
UniqueID

获取服务器控件的唯一的、以分层形式限定的标识符。Gets the unique, hierarchically qualified identifier for the server control.

(继承自 Control)
ValidateRequestMode

获取或设置指示控件是否检查来自浏览器的客户端输入是否具有潜在危险值的值。Gets or sets a value that indicates whether the control checks client input from the browser for potentially dangerous values.

(继承自 Control)
ViewState

获取状态信息的字典,这些信息使您可以在同一页的多个请求间保存和还原服务器控件的视图状态。Gets a dictionary of state information that allows you to save and restore the view state of a server control across multiple requests for the same page.

(继承自 Control)
ViewStateIgnoresCase

获取一个值,该值指示 StateBag 对象是否不区分大小写。Gets a value that indicates whether the StateBag object is case-insensitive.

(继承自 Control)
ViewStateMode

获取或设置此控件的视图状态模式。Gets or sets the view-state mode of this control.

(继承自 Control)
Visible

获取一个值,该值可使子控件可见。Gets a value that enables child controls to be visible.

WebParts

获取对网页上的 WebPart 控件所跟踪的所有 WebPartManager 控件的引用。Gets a reference to all WebPart controls tracked by the WebPartManager control on a Web page.

Zones

获取对网页上所有 WebPartZoneBase 区域的集合的引用。Gets a reference to a collection of all the WebPartZoneBase zones on a Web page.

方法

ActivateConnections()

激活网页上当前所有非活动连接。Makes active all connections on a Web page that are currently inactive.

AddedControl(Control, Int32)

在子控件添加到 Control 对象的 Controls 集合后调用。Called after a child control is added to the Controls collection of the Control object.

(继承自 Control)
AddParsedSubObject(Object)

通知服务器控件,分析了一个元素(XML 或 HTML),并将该元素添加到服务器控件的 ControlCollection 对象中。Notifies the server control that an element, either XML or HTML, was parsed, and adds the element to the server control's ControlCollection object.

(继承自 Control)
AddWebPart(WebPart, WebPartZoneBase, Int32)

提供向网页添加 WebPart 控件的标准编程方法。Provides the standard programmatic method for adding WebPart controls to a Web page.

ApplyStyleSheetSkin(Page)

将页样式表中定义的样式属性应用到控件。Applies the style properties defined in the page style sheet to the control.

(继承自 Control)
BeginRenderTracing(TextWriter, Object)

开始输出数据的设计时追踪。Begins design-time tracing of rendering data.

(继承自 Control)
BeginWebPartConnecting(WebPart)

开始连接两个 WebPart 控件的过程。Starts the process of connecting two WebPart controls.

BeginWebPartEditing(WebPart)

开始 WebPart 控件的编辑过程。Starts the process of editing a WebPart control.

BuildProfileTree(String, Boolean)

收集有关服务器控件的信息并将该信息发送到 Trace 属性,在启用页的跟踪功能时将显示该属性。Gathers information about the server control and delivers it to the Trace property to be displayed when tracing is enabled for the page.

(继承自 Control)
CanConnectWebParts(WebPart, ProviderConnectionPoint, WebPart, ConsumerConnectionPoint)

当使用者和提供者控件有兼容接口且不需要 WebPart 对象时,请检查将参与连接的 WebPartTransformer 控件,以确定它们是否能够被连接。Checks the WebPart controls that will be participating in a connection to determine whether they are capable of being connected, when the consumer and provider controls have compatible interfaces and a WebPartTransformer object is not needed.

CanConnectWebParts(WebPart, ProviderConnectionPoint, WebPart, ConsumerConnectionPoint, WebPartTransformer)

检查将参与连接的 WebPart 控件,以确定这些控件是否能够连接,并使用 WebPartTransformer 对象在不兼容的使用者和提供者之间创建连接。Checks the WebPart controls that will be participating in a connection to determine whether they are capable of being connected, and uses a WebPartTransformer object to create the connection between an incompatible consumer and provider.

CheckRenderClientScript()

检查发出请求的浏览器的功能,并检查 EnableClientScript 属性的值,以确定是否呈现客户端脚本。Checks the capabilities of the browser making the request, and the value of the EnableClientScript property, to determine whether to render client script.

ClearCachedClientID()

将缓存的 ClientID 值设置为 nullSets the cached ClientID value to null.

(继承自 Control)
ClearChildControlState()

删除服务器控件的子控件的控件状态信息。Deletes the control-state information for the server control's child controls.

(继承自 Control)
ClearChildState()

删除服务器控件的所有子控件的视图状态和控件状态信息。Deletes the view-state and control-state information for all the server control's child controls.

(继承自 Control)
ClearChildViewState()

删除服务器控件的所有子控件的视图状态信息。Deletes the view-state information for all the server control's child controls.

(继承自 Control)
ClearEffectiveClientIDMode()

将当前控件实例和任何子控件的 ClientIDMode 属性设置为 InheritSets the ClientIDMode property of the current control instance and of any child controls to Inherit.

(继承自 Control)
CloseWebPart(WebPart)

以不在网页上呈现,但可以重新打开的方式关闭 WebPart 控件。Closes a WebPart control in such a way that it is not rendered on a Web page, but can be reopened.

ConnectWebParts(WebPart, ProviderConnectionPoint, WebPart, ConsumerConnectionPoint)

只使用对控件的引用和控件所指定的 WebPart 对象在两个 GenericWebPartConnectionPoint 控件之间创建连接。Creates a connection between two WebPart or GenericWebPart controls using only the references to the controls and their specified ConnectionPoint objects.

ConnectWebParts(WebPart, ProviderConnectionPoint, WebPart, ConsumerConnectionPoint, WebPartTransformer)

使用对两个 WebPartGenericWebPart 控件的引用、它们的指定 ConnectionPoint 对象和一个 WebPartTransformer 对象在这两个控件之间创建连接。Creates a connection between two WebPart or GenericWebPart controls using the references to the controls, their specified ConnectionPoint objects, and a WebPartTransformer object.

CopyWebPart(WebPart)

由 Web 部件控件集用来创建 WebPart 或服务器控件的副本,以向网页中添加该控件。Used by the Web Parts control set to create a copy of a WebPart or server control for the purpose of adding the control to a Web page.

CreateAvailableTransformers()

创建一组在网站配置文件中指定的转换器,并将它们添加到 AvailableTransformers 属性所引用的转换器的集合。Creates a set of transformers specified in a Web site's configuration file and adds them to the collection of transformers referenced by the AvailableTransformers property.

CreateChildControls()

由 ASP.NET 页框架调用,以通知服务器控件在准备回发或呈现时使用基于撰写的实现来创建其所包含任何子控件。Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.

(继承自 Control)
CreateControlCollection()

返回网页上的 WebPartManager 控件所管理的所有控件的集合。Returns the collection of all controls that are managed by the WebPartManager control on a Web page. 此类不能被继承。This class cannot be inherited.

CreateDisplayModes()

为 Web 部件应用程序创建由所有可能的显示模式组成的显示模式集。Creates the set of all possible display modes for a Web Parts application.

CreateDynamicConnectionID()

获取一个唯一值,用于充当动态连接的 ID。Gets a unique value to serve as an ID for a dynamic connection.

CreateDynamicWebPartID(Type)

为动态 WebPart 控件生成唯一 ID。Generates a unique ID for a dynamic WebPart control.

CreateErrorWebPart(String, String, String, String, String)

当加载或创建动态 WebPart 控件的尝试因某种原因失败时,创建插入页中并向最终用户显示的特殊控件。Creates a special control that is inserted into a page and displayed for end users, when an attempt to load or create a dynamic WebPart control fails for some reason.

CreatePersonalization()

返回一个个性化设置对象,该对象包含当前网页的用户个性化设置数据。Returns a personalization object to contain a user's personalization data for the current Web page.

CreateWebPart(Control)

WebPart 对象包装一个不是 GenericWebPart 控件的服务器控件,以使该控件能具有 Web 部件的功能。Wraps a server control that is not a WebPart control with a GenericWebPart object, so that the control can have Web Parts functionality.

DataBind()

将数据源绑定到调用的服务器控件及其所有子控件。Binds a data source to the invoked server control and all its child controls.

(继承自 Control)
DataBind(Boolean)

将数据源绑定到调用的服务器控件及其所有子控件,同时可以选择引发 DataBinding 事件。Binds a data source to the invoked server control and all its child controls with an option to raise the DataBinding event.

(继承自 Control)
DataBindChildren()

将数据源绑定到服务器控件的子控件。Binds a data source to the server control's child controls.

(继承自 Control)
DeleteWebPart(WebPart)

永久地从网页中移除 WebPart 控件的动态实例。Permanently removes a dynamic instance of a WebPart control from a Web page.

DisconnectWebPart(WebPart)

移除要关闭或要从其所参与的连接中删除的 WebPart 或服务器控件。Removes a WebPart or server control that is being closed or deleted from any connections it is participating in.

DisconnectWebParts(WebPartConnection)

执行断开网页中连接的服务器控件的过程。Carries out the process of disconnecting server controls that are connected on a Web page.

Dispose()

使服务器控件得以在从内存中释放之前执行最后的清理操作。Enables a server control to perform final clean up before it is released from memory.

(继承自 Control)
EndRenderTracing(TextWriter, Object)

结束输出数据的设计时追踪。Ends design-time tracing of rendering data.

(继承自 Control)
EndWebPartConnecting()

完成将 WebPart 控件连接到另一个控件的过程。Completes the process of connecting a WebPart control to another control.

EndWebPartEditing()

完成编辑 WebPart 控件的过程。Completes the process of editing a WebPart control.

EnsureChildControls()

确定服务器控件是否包含子控件。Determines whether the server control contains child controls. 如果不包含,则创建子控件。If it does not, it creates child controls.

(继承自 Control)
EnsureID()

为尚未分配标识符的控件创建标识符。Creates an identifier for controls that do not have an identifier assigned.

(继承自 Control)
Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
ExportWebPart(WebPart, XmlWriter)

创建包含服务器控件的状态和属性数据的 XML 说明文件。Creates an XML description file that contains state and property data for a server control.

FindControl(String)

在当前的命名容器中搜索带指定 id 参数的服务器控件。Searches the current naming container for a server control with the specified id parameter.

(继承自 Control)
FindControl(String, Int32)

使用指定的 idpathOffset 参数(该参数有助于搜索)中指定的整数在当前命名容器中搜索服务器控件。Searches the current naming container for a server control with the specified id and an integer, specified in the pathOffset parameter, which aids in the search. 不应重写此版本的 FindControl 方法。You should not override this version of the FindControl method.

(继承自 Control)
Focus()

被重写以防止将焦点设置在 WebPartManager 控件上,因为该控件没有用户界面 (UI)。Overridden to prevent focus from ever being set on the WebPartManager control, because it has no user interface (UI).

GetConsumerConnectionPoints(WebPart)

检索 ConsumerConnectionPoint 对象的集合,这些对象可以作为来自如下服务器控件的连接点:该服务器控件正在作为 Web 部件连接中的使用者。Retrieves the collection of ConsumerConnectionPoint objects that can act as connection points from a server control that is acting as a consumer within a Web Parts connection.

GetCurrentWebPartManager(Page)

检索对页上的 WebPartManager 控件的当前实例的引用。Retrieves a reference to the current instance of the WebPartManager control on a page.

GetDesignModeState()

获取控件的设计时数据。Gets design-time data for a control.

(继承自 Control)
GetDisplayTitle(WebPart)

获取一个字符串,其中包含 DisplayTitle 控件的 WebPart 属性的值。Gets a string containing the value for the DisplayTitle property of a WebPart control.

GetExportUrl(WebPart)

获取当用户尝试导出 WebPart 控件时包含在请求中的相对虚拟路径和查询字符串。Gets the relative virtual path and the query string that are part of the request when a user attempts to export a WebPart control.

GetGenericWebPart(Control)

获取对 GenericWebPart 控件的实例的引用,该实例包含一个服务器控件。Gets a reference to the instance of the GenericWebPart control that contains a server control.

GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetProviderConnectionPoints(WebPart)

检索 ProviderConnectionPoint 对象的集合,这些对象可作为来自如下服务器控件的连接点:该服务器控件正在作为 Web 部件连接中的提供者。Retrieves the collection of ProviderConnectionPoint objects that can act as connection points from a server control that is acting as a provider within a Web Parts connection.

GetRouteUrl(Object)

获取与一组路由参数对应的 URL。Gets the URL that corresponds to a set of route parameters.

(继承自 Control)
GetRouteUrl(RouteValueDictionary)

获取与一组路由参数对应的 URL。Gets the URL that corresponds to a set of route parameters.

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

获取与一组路由参数以及某个路由名称对应的 URL。Gets the URL that corresponds to a set of route parameters and a route name.

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

获取与一组路由参数以及某个路由名称对应的 URL。Gets the URL that corresponds to a set of route parameters and a route name.

(继承自 Control)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
GetUniqueIDRelativeTo(Control)

返回指定控件的 UniqueID 属性的前缀部分。Returns the prefixed portion of the UniqueID property of the specified control.

(继承自 Control)
HasControls()

确定服务器控件是否包含任何子控件。Determines if the server control contains any child controls.

(继承自 Control)
HasEvents()

返回一个值,该值指示是否为控件或任何子控件注册事件。Returns a value indicating whether events are registered for the control or any child controls.

(继承自 Control)
ImportWebPart(XmlReader, String)

导入包含 WebPart 控件的状态和属性数据的 XML 说明文件,并将这些数据应用于控件。Imports an XML description file that contains state and property data for a WebPart control, and applies the data to the control.

IsAuthorized(Type, String, String, Boolean)

执行确定控件是否已经过授权可添加至页的最后步骤。Carries out the final steps in determining whether a control is authorized to be added to a page.

IsAuthorized(WebPart)

执行确定控件是否被授权添加到页中的初始步骤。Carries out the initial steps in determining whether a control is authorized to be added to a page.

IsLiteralContent()

确定服务器控件是否只包含文字内容。Determines if the server control holds only literal content.

(继承自 Control)
LoadControlState(Object)

加载从前一个页请求保存并需要在后续请求上还原的控件状态数据。Loads control state data that was saved from a previous page request, and needs to be restored on a subsequent request.

LoadCustomPersonalizationState(PersonalizationDictionary)

存储由个性化对象传递给 WebPartManager 控件的自定义个性化数据,稍后会将其用于初始化过程中。Stores the custom personalization data that has been passed to the WebPartManager control by the personalization objects to be used later during the initialization process.

LoadViewState(Object)

从用 SaveViewState() 方法保存的上一个页面请求还原视图状态信息。Restores view-state information from a previous page request that was saved by the SaveViewState() method.

(继承自 Control)
MapPathSecure(String)

检索虚拟路径(绝对的或相对的)映射到的物理路径。Retrieves the physical path that a virtual path, either absolute or relative, maps to.

(继承自 Control)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
MoveWebPart(WebPart, WebPartZoneBase, Int32)

WebPart 或服务器控件从一个 WebPartZoneBase 区域移动到另一个区域,或移动到相同区域中的新位置。Moves a WebPart or server control from one WebPartZoneBase zone to another, or to a new position within the same zone.

OnAuthorizeWebPart(WebPartAuthorizationEventArgs)

引发 AuthorizeWebPart 事件并调用该事件的处理程序(如果存在)。Raises the AuthorizeWebPart event and invokes a handler for the event, if one exists.

OnBubbleEvent(Object, EventArgs)

确定服务器控件的事件是否沿页的 UI 服务器控件层次结构向上传递。Determines whether the event for the server control is passed up the page's UI server control hierarchy.

(继承自 Control)
OnConnectionsActivated(EventArgs)

引发 ConnectionsActivated 事件以指示已加载页及其控件,并且已激活页上的连接,可以开始共享数据。Raises the ConnectionsActivated event to indicate that a page and its controls are loaded, and connections on the page have been activated to begin sharing data.

OnConnectionsActivating(EventArgs)

引发 ConnectionsActivating 事件以指示已加载页及其控件,可以开始激活连接的过程。Raises the ConnectionsActivating event to indicate that a page and its controls have loaded, and the process of activating connections can begin.

OnDataBinding(EventArgs)

引发 DataBinding 事件。Raises the DataBinding event.

(继承自 Control)
OnDisplayModeChanged(WebPartDisplayModeEventArgs)

引发 DisplayModeChanged 事件,以指示 WebPartManager 控件在网页上已完成从一种显示模式切换到另一种显示模式的过程。Raises the DisplayModeChanged event to indicate that the WebPartManager control has completed the process of switching from one display mode to another on a Web page.

OnDisplayModeChanging(WebPartDisplayModeCancelEventArgs)

引发 DisplayModeChanging 事件,以指示 WebPartManager 控件在网页上正处于从一种显示模式切换到另一种显示模式的过程中。Raises the DisplayModeChanging event to indicate that the WebPartManager control is in the process of switching from one display mode to another on a Web page.

OnInit(EventArgs)

引发 Init 事件,该事件是 WebPartManager 控件生命周期中的第一个事件。Raises the Init event, which is the first event in the WebPartManager control life cycle.

OnLoad(EventArgs)

引发 Load 事件。Raises the Load event.

(继承自 Control)
OnPreRender(EventArgs)

引发 PreRender 事件,该事件恰好在 WebPartManager 控件被呈现在网页上之前发生。Raises the PreRender event, which occurs just before a WebPartManager control is rendered on a Web page.

OnSelectedWebPartChanged(WebPartEventArgs)

引发 SelectedWebPartChanged 事件,该事件在新选择了某个 WebPart 控件或清除对它的选择之后发生。Raises the SelectedWebPartChanged event, which occurs after a WebPart control has either been newly selected or had its selection cleared.

OnSelectedWebPartChanging(WebPartCancelEventArgs)

引发 SelectedWebPartChanging 事件,该事件在更改当前选择的 WebPart 控件的过程中发生。Raises the SelectedWebPartChanging event, which occurs during the process of changing which WebPart control is currently selected.

OnUnload(EventArgs)

引发基 Unload 事件,并从网页中移除 WebPartManager 实例。Raises the base Unload event and removes the WebPartManager instance from a Web page.

OnWebPartAdded(WebPartEventArgs)

引发 WebPartAdded 事件,该事件在 WebPart 控件已被添加到某个页之后发生。Raises the WebPartAdded event, which occurs after a WebPart control has been added to a page.

OnWebPartAdding(WebPartAddingEventArgs)

引发 WebPartAdding 事件,该事件将在向 WebPart 区域添加 WebPartZoneBase 控件(或服务器控件,或用户控件)的过程中发生。Raises the WebPartAdding event, which occurs during the process of adding a WebPart control (or a server or user control) to a WebPartZoneBase zone.

OnWebPartClosed(WebPartEventArgs)

引发 WebPartClosed 事件以表明控件已从页中移除。Raises the WebPartClosed event to signal that a control has been removed from a page.

OnWebPartClosing(WebPartCancelEventArgs)

引发 WebPartClosing 事件,该事件将在从页中移除 WebPart 或服务器控件的过程中发生。Raises the WebPartClosing event, which occurs during the process of a WebPart or server control being removed from a page.

OnWebPartDeleted(WebPartEventArgs)

引发 WebPartDeleted 事件,该事件在从页中永久删除 WebPart 控件之后发生。Raises the WebPartDeleted event, which occurs after a WebPart control has been permanently deleted from a page.

OnWebPartDeleting(WebPartCancelEventArgs)

引发 WebPartDeleting 事件,该事件指示动态 WebPart 控件(或 WebPartZoneBase 区域中包含的服务器控件或用户控件)正处于被删除的过程中。Raises the WebPartDeleting event, which indicates that a dynamic WebPart control (or server or user control that is contained in a WebPartZoneBase zone) is in the process of being deleted.

OnWebPartMoved(WebPartEventArgs)

引发 WebPartMoved 事件,该事件在 WebPart 控件已被移动到页上的不同位置之后发生。Raises the WebPartMoved event, which occurs after a WebPart control has been moved to a different location on a page.

OnWebPartMoving(WebPartMovingEventArgs)

引发 WebPartMoving 事件,该事件指示 WebPart 区域中的 WebPartZoneBase、服务器控件或用户控件正处于移动过程中。Raises the WebPartMoving event, which indicates that a WebPart or server or user control in a WebPartZoneBase zone is in the process of being moved.

OnWebPartsConnected(WebPartConnectionsEventArgs)

引发 WebPartsConnected 事件,该事件在 WebPart 控件之间建立了连接之后发生。Raises the WebPartsConnected event, which occurs after a connection has been established between WebPart controls.

OnWebPartsConnecting(WebPartConnectionsCancelEventArgs)

引发 WebPartsConnecting 事件,该事件发生于在 WebPart 区域内包含的两个 WebPartZoneBase 或服务器控件或用户控件之间建立连接的过程中。Raises the WebPartsConnecting event, which occurs during the process of establishing a connection between two WebPart or server or user controls contained in a WebPartZoneBase zone.

OnWebPartsDisconnected(WebPartConnectionsEventArgs)

引发 WebPartsDisconnected 事件,该事件在 WebPart 控件之间的连接已终止之后发生。Raises the WebPartsDisconnected event, which occurs after a connection between WebPart controls has ended.

OnWebPartsDisconnecting(WebPartConnectionsCancelEventArgs)

引发 WebPartsDisconnecting 事件,该事件指示 WebPart 区域中的两个 WebPartZoneBase 或服务器控件或用户控件正处于结束连接的过程中。Raises the WebPartsDisconnecting event, which indicates that two WebPart or server or user controls in a WebPartZoneBase zone are in the process of ending a connection.

OpenFile(String)

获取用于读取文件的 StreamGets a Stream used to read a file.

(继承自 Control)
RaiseBubbleEvent(Object, EventArgs)

将所有事件源及其信息分配给控件的父级。Assigns any sources of the event and its information to the control's parent.

(继承自 Control)
RegisterClientScript()

使 WebPartManager 控件能够发出用于各种个性化设置功能(例如,在网页中拖动 WebPart 控件)的客户端脚本。Enables the WebPartManager control to emit client-side script that is used for various personalization features, such as dragging WebPart controls in a Web page.

RemovedControl(Control)

Control 对象的 Controls 集合移除子控件后调用。Called after a child control is removed from the Controls collection of the Control object.

(继承自 Control)
Render(HtmlTextWriter)

重写以防止 WebPartManager 控件呈现任何内容。Overridden to prevent the WebPartManager control from rendering any content.

RenderChildren(HtmlTextWriter)

将服务器控件子级的内容输出到提供的 HtmlTextWriter 对象,此对象编写将在客户端呈现的内容。Outputs the content of a server control's children to a provided HtmlTextWriter object, which writes the content to be rendered on the client.

(继承自 Control)
RenderControl(HtmlTextWriter)

将服务器控件内容输出到所提供的 HtmlTextWriter 对象,如果启用了跟踪,则还将存储有关该控件的跟踪信息。Outputs server control content to a provided HtmlTextWriter object and stores tracing information about the control if tracing is enabled.

(继承自 Control)
RenderControl(HtmlTextWriter, ControlAdapter)

使用提供的 HtmlTextWriter 对象将服务器控件内容输出到提供的 ControlAdapter 对象。Outputs server control content to a provided HtmlTextWriter object using a provided ControlAdapter object.

(继承自 Control)
ResolveAdapter()

获取负责呈现指定控件的控件适配器。Gets the control adapter responsible for rendering the specified control.

(继承自 Control)
ResolveClientUrl(String)

获取浏览器可以使用的 URL。Gets a URL that can be used by the browser.

(继承自 Control)
ResolveUrl(String)

将 URL 转换为在请求客户端可用的 URL。Converts a URL into one that is usable on the requesting client.

(继承自 Control)
SaveControlState()

保存 WebPartManager 控件的状态数据,以便在将来请求包含该控件的网页时可以还原这些数据。Saves state data for the WebPartManager control so the data can be restored on future request to the Web page that contains the control.

SaveCustomPersonalizationState(PersonalizationDictionary)

保存由 WebPartManager 控件维护的自定义个性化设置状态数据,以便重新加载该页时可以重新加载此数据。Saves custom personalization state data maintained by the WebPartManager control, so that this data can be reloaded whenever the page is reloaded.

SaveViewState()

保存将页面回发到服务器之后发生的所有服务器控件视图状态更改。Saves any server control view-state changes that have occurred since the time the page was posted back to the server.

(继承自 Control)
SetDesignModeState(IDictionary)

为控件设置设计时数据。Sets design-time data for a control.

(继承自 Control)
SetPersonalizationDirty()

设置一个标志,该标志指示 WebPartManager 控件的自定义个性化设置数据已更改。Sets a flag indicating that custom personalization data for the WebPartManager control has changed.

SetRenderMethodDelegate(RenderMethod)

分配事件处理程序委托,以将服务器控件及其内容呈现到父控件中。Assigns an event handler delegate to render the server control and its content into its parent control.

(继承自 Control)
SetSelectedWebPart(WebPart)

SelectedWebPart 属性值设置为等于当前选定的 WebPart 或服务器控件。Sets the SelectedWebPart property value equal to the currently selected WebPart or server control.

SetTraceData(Object, Object)

使用跟踪数据键和跟踪数据值,为呈现数据的设计时追踪设置跟踪数据。Sets trace data for design-time tracing of rendering data, using the trace data key and the trace data value.

(继承自 Control)
SetTraceData(Object, Object, Object)

使用跟踪对象、跟踪数据键和跟踪数据值,为呈现数据的设计时追踪设置跟踪数据。Sets trace data for design-time tracing of rendering data, using the traced object, the trace data key, and the trace data value.

(继承自 Control)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)
TrackViewState()

将个性化设置状态数据应用到 WebPartManager 控件,调用基方法以便能够跟踪对控件视图状态数据的更改。Applies personalization state data to the WebPartManager control, and calls the base method to enable tracking changes to the view-state data for the control.

事件

AuthorizeWebPart

当调用 IsAuthorized 方法以确定 WebPart 或服务器控件是否能够添加到页中时发生。Occurs when the IsAuthorized method is called to determine whether a WebPart or server control can be added to a page.

ConnectionsActivated

在页上的所有当前 Web 部件连接不仅已经连接,而且已经开始在每个连接所涉及的使用者控件和提供者控件之间共享数据之后发生。Occurs after all the current Web Parts connections on a page are not only connected, but have also begun actively sharing data between the consumer and provider controls involved in each connection.

ConnectionsActivating

在激活网页上所有已建立的 Web 部件连接的过程中发生。Occurs during the process of activating all the established Web Parts connections on a Web page.

DataBinding

当服务器控件绑定到数据源时发生。Occurs when the server control binds to a data source.

(继承自 Control)
DisplayModeChanged

当 Web 部件页上的当前显示模式更改之后发生。Occurs after the current display mode on a Web Parts page has changed.

DisplayModeChanging

当用户单击网页上的谓词以启动不同显示模式之间的更改过程之后发生。Occurs after a user clicks a verb on a Web page that begins the process of changing to a different display mode.

Disposed

当从内存释放服务器控件时发生,这是请求 ASP.NET 页时服务器控件生存期的最后阶段。Occurs when a server control is released from memory, which is the last stage of the server control lifecycle when an ASP.NET page is requested.

(继承自 Control)
Init

当服务器控件初始化时发生;初始化是控件生存期的第一步。Occurs when the server control is initialized, which is the first step in its lifecycle.

(继承自 Control)
Load

当服务器控件加载到 Page 对象中时发生。Occurs when the server control is loaded into the Page object.

(继承自 Control)
PreRender

在加载 Control 对象之后、呈现之前发生。Occurs after the Control object is loaded but prior to rendering.

(继承自 Control)
SelectedWebPartChanged

在对一个 WebPart 控件的选择已经发生更改并被移动到网页上的另一个控件之后发生。Occurs after the selection of one WebPart control has changed and moved to another control on a Web page.

SelectedWebPartChanging

在更改网页上 WebPart 或服务器控件当前的选定状态的过程中发生。Occurs during the process of changing which WebPart or server control is currently selected on a Web page.

Unload

当服务器控件从内存中卸载时发生。Occurs when the server control is unloaded from memory.

(继承自 Control)
WebPartAdded

在动态 WebPart 或其他服务器控件已被添加到 WebPartZoneBase 区域之后发生,以指示已成功添加了控件。Occurs after a dynamic WebPart or other server control has been added to a WebPartZoneBase zone, to indicate that the control was added successfully.

WebPartAdding

在向 WebPart 区域添加动态 WebPartZoneBase 或其他服务器控件的过程中发生。Occurs during the process of adding a dynamic WebPart or other server control to a WebPartZoneBase zone.

WebPartClosed

当从页中移除 WebPart 控件(或服务器控件,或用户控件)时发生。Occurs when a WebPart control (or server or user control) is removed from a page.

WebPartClosing

在从页中移除 WebPart 控件(或服务器控件,或用户控件)的过程中发生。Occurs during the process of removing a WebPart control (or server or user control) from a page.

WebPartDeleted

WebPart 或其他服务器控件已从 WebPartZoneBase 区域删除之后发生。Occurs after a WebPart or other server control has been deleted from a WebPartZoneBase zone.

WebPartDeleting

在从 WebPart 区域中永久删除动态 WebPartZoneBase 或其他服务器控件的实例的过程中发生。Occurs during the process of permanently deleting an instance of a dynamic WebPart or other server control from a WebPartZoneBase zone.

WebPartMoved

WebPart 或服务器控件已被移动到网页上的不同位置之后发生。Occurs after a WebPart or server control has been moved to a different location on a Web page.

WebPartMoving

在移动 WebPart 区域中包含的 WebPartZoneBase 或其他服务器控件的过程中发生。Occurs during the process of moving a WebPart or other server control that is contained in a WebPartZoneBase zone.

WebPartsConnected

WebPart 控件(或者服务器或用户控件)之间已建立特定连接之后发生。Occurs after a specific connection has been established between WebPart controls (or server or user controls).

WebPartsConnecting

在创建 WebPart 控件(或放置在 WebPartZoneBase 区域中的服务器控件或用户控件)之间的连接的过程中发生。Occurs during the process of creating a connection between WebPart controls (or server or user controls placed in a WebPartZoneBase zone).

WebPartsDisconnected

在两个 WebPart 或服务器控件之间的连接已终止之后发生。Occurs after a connection between two WebPart or server controls has been terminated.

WebPartsDisconnecting

在结束以前连接的 WebPart 或服务器控件之间的连接的过程中发生。Occurs during the process of ending the connection between previously connected WebPart or server controls.

显式接口实现

IControlBuilderAccessor.ControlBuilder

有关此成员的说明,请参见 ControlBuilderFor a description of this member, see ControlBuilder.

(继承自 Control)
IControlDesignerAccessor.GetDesignModeState()

有关此成员的说明,请参见 GetDesignModeState()For a description of this member, see GetDesignModeState().

(继承自 Control)
IControlDesignerAccessor.SetDesignModeState(IDictionary)

有关此成员的说明,请参见 SetDesignModeState(IDictionary)For a description of this member, see SetDesignModeState(IDictionary).

(继承自 Control)
IControlDesignerAccessor.SetOwnerControl(Control)

有关此成员的说明,请参见 SetOwnerControl(Control)For a description of this member, see SetOwnerControl(Control).

(继承自 Control)
IControlDesignerAccessor.UserData

有关此成员的说明,请参见 UserDataFor a description of this member, see UserData.

(继承自 Control)
IDataBindingsAccessor.DataBindings

有关此成员的说明,请参见 DataBindingsFor a description of this member, see DataBindings.

(继承自 Control)
IDataBindingsAccessor.HasDataBindings

有关此成员的说明,请参见 HasDataBindingsFor a description of this member, see HasDataBindings.

(继承自 Control)
IExpressionsAccessor.Expressions

有关此成员的说明,请参见 ExpressionsFor a description of this member, see Expressions.

(继承自 Control)
IExpressionsAccessor.HasExpressions

有关此成员的说明,请参见 HasExpressionsFor a description of this member, see HasExpressions.

(继承自 Control)
IParserAccessor.AddParsedSubObject(Object)

有关此成员的说明,请参见 AddParsedSubObject(Object)For a description of this member, see AddParsedSubObject(Object).

(继承自 Control)
IPersonalizable.IsDirty

获取一个值,该值指示 WebPartManager 控件管理的自定义个性化设置状态数据是否已在网页上更改。Gets a value that indicates whether custom personalization state data managed by the WebPartManager control has changed on a Web page.

IPersonalizable.Load(PersonalizationDictionary)

返回先前保存的需要加载到 WebPartManager 控件的自定义个性化状态数据。Returns previously saved custom personalization state data that needs to be loaded to the WebPartManager control.

IPersonalizable.Save(PersonalizationDictionary)

保存由 WebPartManager 控件管理的自定义个性化设置状态数据。Saves custom personalization state data that is managed by the WebPartManager control.

扩展方法

FindDataSourceControl(Control)

返回与指定控件的数据控件关联的数据源。Returns the data source that is associated with the data control for the specified control.

FindFieldTemplate(Control, String)

返回指定控件的命名容器中指定列的字段模板。Returns the field template for the specified column in the specified control's naming container.

FindMetaTable(Control)

返回包含数据控件的元表对象。Returns the metatable object for the containing data control.

GetDefaultValues(INamingContainer)

为指定数据控件获取默认值的集合。Gets the collection of the default values for the specified data control.

GetMetaTable(INamingContainer)

为指定数据控件获取表元数据。Gets the table metadata for the specified data control.

SetMetaTable(INamingContainer, MetaTable)

为指定数据控件设置表元数据。Sets the table metadata for the specified data control.

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

为指定数据控件设置表元数据和默认值映射。Sets the table metadata and default value mapping for the specified data control.

SetMetaTable(INamingContainer, MetaTable, Object)

为指定数据控件设置表元数据和默认值映射。Sets the table metadata and default value mapping for the specified data control.

TryGetMetaTable(INamingContainer, MetaTable)

确定表元数据是否可用。Determines whether table metadata is available.

EnableDynamicData(INamingContainer, Type)

为指定数据控件启用动态数据行为。Enables Dynamic Data behavior for the specified data control.

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

为指定数据控件启用动态数据行为。Enables Dynamic Data behavior for the specified data control.

EnableDynamicData(INamingContainer, Type, Object)

为指定数据控件启用动态数据行为。Enables Dynamic Data behavior for the specified data control.

适用于

另请参阅