Rediger

Del via


ConnectionsZone Constructor

Definition

Initializes a new instance of the ConnectionsZone class.

public:
 ConnectionsZone();
public ConnectionsZone ();
Public Sub New ()

Examples

The following code example demonstrates the use of the ConnectionsZone constructor to create a new instance of a ConnectionsZone control to add to a Web page programmatically. The example contains only the code for the Web page that demonstrates use of the constructor; for the other two code files needed to run the example, see the Example section of the ConnectionsZone class overview. The code example has four parts:

  • A user control that enables you to switch display modes on the Web page. Obtain this code from the ConnectionsZone class overview.

  • A source file that contains the code for a ZIP Code interface, and two WebPart controls acting as the provider and the consumer for a connection. Obtain this code from the ConnectionsZone class overview.

  • A Web page that hosts all the controls and, in its Page_Init method, uses the ConnectionsZone constructor to create a new instance of the ConnectionsZone control and add it to the page.

  • An explanation of how the example works in a browser.

On the Web page, in the Page_Init method, a new ConnectionsZone control is created (using the constructor) and added to the page. When a user sets the page to connect mode and clicks the connect verb on one of the WebPart controls, a ConnectionsZone control appears.

<%@ 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_Init(object sender, EventArgs e)
  {
    ConnectionsZone connZone = new ConnectionsZone();
    connZone.ID = "connectionsZone1";
    connZone.HeaderText = "Connections Zone 1";
    form1.Controls.AddAt(form1.Controls.Count - 1, connZone);
  }
</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>
  </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_Init(ByVal sender As Object, _
    ByVal e As System.EventArgs)
    
    Dim connZone As ConnectionsZone = New ConnectionsZone()
    connZone.ID = "connectionsZone1"
    connZone.HeaderText = "Connections Zone 1"
    form1.Controls.AddAt(form1.Controls.Count - 1, connZone)

  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>
  </div>
  </form>
</body>
</html>

Load the page in a browser. Switch to connect mode, using the Display Mode control. Click the verbs menu arrow on the ZIP Code Provider control, and click the connect verb. The connection UI appears, and the controls are already connected because the connection was declared in the markup of the page.

Remarks

This parameterless constructor is called when you declare the <asp:connectionszone> element in an ASP.NET page. You do not need to implicitly call this constructor, except in cases where you are adding the control to the page programmatically.

Applies to

See also