ProxyWebPartManager.StaticConnections Propriedade
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Obtém uma coleção de ligações estáticas declaradas dentro do <asp:proxywebpartmanager> elemento numa página de conteúdo.
public:
property System::Web::UI::WebControls::WebParts::ProxyWebPartConnectionCollection ^ StaticConnections { System::Web::UI::WebControls::WebParts::ProxyWebPartConnectionCollection ^ get(); };
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
public System.Web.UI.WebControls.WebParts.ProxyWebPartConnectionCollection StaticConnections { get; }
[<System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)>]
member this.StaticConnections : System.Web.UI.WebControls.WebParts.ProxyWebPartConnectionCollection
Public ReadOnly Property StaticConnections As ProxyWebPartConnectionCollection
Valor de Propriedade
A que contém todos os objetos estáticos ProxyWebPartConnectionCollectionWebPartConnection declarados dentro de um <asp:proxywebpartmanager> elemento.
- Atributos
Exemplos
O exemplo de código seguinte demonstra como usar a StaticConnections propriedade na ProxyWebPartManager classe. Este exemplo de código mostra apenas a parte relevante do código da página de conteúdo que declara o ProxyWebPartManager controlo e a ligação estática. Para as outras páginas necessárias para executar o exemplo de código e uma descrição de como as configurar, consulte a secção Exemplo da ProxyWebPartManager visão geral da classe.
O código seguinte é a página de conteúdo que declara o <staticconnections> elemento como filho do <asp:proxywebpartmanager> elemento. Note também que o Button1_Click método verifica a contagem da StaticConnections propriedade no ProxyWebPartManager controlo e escreve-a na página.
<%@ Page Language="C#" MasterPageFile="~/MasterPageCS.master"
Title="Connections Page" %>
<%@ Register TagPrefix="aspSample"
Namespace="Samples.AspNet.CS.Controls" %>
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
StringBuilder lblText = new StringBuilder();
if (Page.Master.FindControl("WebPartManager1") != null)
{
WebPartManager theMgr =
(WebPartManager)Page.Master.FindControl("WebPartManager1");
lblText.Append("WebPartManager: <br /><pre>" +
" Master page file is " + Page.MasterPageFile + "<br />" +
" ID is " + theMgr.ID + "<br />" +
" Connection count is " +
theMgr.StaticConnections.Count.ToString() + "<br />" +
" WebParts count is " +
theMgr.WebParts.Count.ToString() + "</pre><br />");
}
if (proxymgr1 != null)
{
lblText.Append("ProxyWebPartManager: <br /><pre>" +
" Content page file is " + Request.Path + "<br />" +
" ID is " + proxymgr1.ID + "<br />" +
" Connection count is " +
proxymgr1.StaticConnections.Count.ToString() +
"</pre><br />");
}
Literal1.Text = lblText.ToString();
}
</script>
<asp:Content ID="Content1" Runat="Server"
ContentPlaceHolderID="ContentPlaceHolder1" >
<asp:proxywebpartmanager id="proxymgr1" runat="server">
<staticconnections>
<asp:webpartconnection id="connection1"
consumerconnectionpointid="ZipCodeConsumer"
consumerid="zipConsumer"
providerconnectionpointid="ZipCodeProvider"
providerid="zipProvider" />
</staticconnections>
</asp:proxywebpartmanager>
<div>
<asp:webpartzone id="zone1" 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>
</div>
<div>
<asp:button id="Button1" runat="server"
text="WebPartManager Information" onclick="Button1_Click" />
<br />
</div>
<asp:connectionszone id="ConnectionsZone1" runat="server" />
<asp:literal id="Literal1" runat="server" />
</asp:Content>
<%@ Page Language="VB" MasterPageFile="~/MasterPageVB.master"
Title="Connections Page" %>
<%@ Register TagPrefix="aspSample"
Namespace="Samples.AspNet.VB.Controls" %>
<script runat="server">
Protected Sub Button1_Click(ByVal sender As Object, _
ByVal e As EventArgs)
Dim lblText As StringBuilder = New StringBuilder()
If Not (Page.Master.FindControl("WebPartManager1") Is Nothing) Then
Dim theMgr As WebPartManager = _
CType(Page.Master.FindControl("WebPartManager1"), WebPartManager)
lblText.Append("WebPartManager: <br /><pre>" & _
" Master page file is " & Page.MasterPageFile & "<br />" & _
" ID is " & theMgr.ID & "<br />" & _
" Connection count is " & _
theMgr.StaticConnections.Count.ToString() & "<br />" & _
" WebParts count is " & _
theMgr.WebParts.Count.ToString() & "</pre><br />")
End If
If Not (proxymgr1 Is Nothing) Then
lblText.Append("ProxyWebPartManager: <br /><pre>" & _
" Content page file is " & Request.Path & "<br />" & _
" ID is " & proxymgr1.ID & "<br />" & _
" Connection count is " & _
proxymgr1.StaticConnections.Count.ToString() & "</pre><br />")
End If
Literal1.Text = lblText.ToString()
End Sub
</script>
<asp:Content ID="Content1" Runat="Server"
ContentPlaceHolderID="ContentPlaceHolder1" >
<asp:proxywebpartmanager id="proxymgr1" runat="server">
<staticconnections>
<asp:webpartconnection id="connection1"
consumerconnectionpointid="ZipCodeConsumer"
consumerid="zipConsumer"
providerconnectionpointid="ZipCodeProvider"
providerid="zipProvider" />
</staticconnections>
</asp:proxywebpartmanager>
<div>
<asp:webpartzone id="zone1" 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>
</div>
<div>
<asp:button id="Button1" runat="server"
text="WebPartManager Information" onclick="Button1_Click" />
<br />
<asp:literal id="Literal1" runat="server" />
</div>
<asp:connectionszone id="ConnectionsZone1" runat="server" />
</asp:Content>
Depois de carregar a página num navegador, clique no botão WebPartManager Information e observe a informação sobre o WebPartManager controlo na página mestre e o ProxyWebPartManager controlo na página de conteúdo. Por exemplo, note que ambos têm a mesma contagem nas respetivas propriedades que acompanham ligações estáticas (a StaticConnections propriedade).
Observações
A StaticConnections propriedade refere-se à coleção de WebPartConnection objetos declarados num <asp:proxywebpartmanager> elemento. As ligações contidas nesta coleção são adicionadas às ligações estáticas dos WebPartManager controlos (referenciadas pela sua WebPartManager.StaticConnections coleção) e tratadas exatamente como quaisquer outras ligações associadas ao WebPartManager controlo.
O elemento declarativo que corresponde à StaticConnections propriedade é o <staticconnections> elemento. Numa aplicação que utiliza páginas-mestre, o <staticconnections> elemento é adicionado como filho do <asp:proxywebpartmanager> elemento numa página de conteúdo, e um <asp:webpartconnection> elemento, por sua vez, é adicionado como filho desse <staticconnections> elemento. Múltiplos <asp:webpartconnection> elementos podem ser adicionados a um só <staticconnections> elemento, e múltiplas páginas de conteúdo podem declarar ligações estáticas como parte de uma aplicação de páginas mestres.