This documentation is archived and is not being maintained.

WebPartConnection::IsShared Property

Gets a value that indicates whether a WebPartConnection object is visible to all users or only to the current user.

Namespace:  System.Web.UI.WebControls.WebParts
Assembly:  System.Web (in System.Web.dll)

[BrowsableAttribute(false)]
public:
property bool IsShared {
	bool get ();
}

Property Value

Type: System::Boolean
true if the connection is shared; otherwise, false.

As with individual WebPart controls, a WebPartConnection object can be a shared or a per-user instance. A shared instance means that the connection is visible to all users of a Web page, and a per-user instance means the connection is visible only to a specific user.

In general, the way a connection is added to a page determines whether the connection is shared. If the connection is declared in the markup of a Web page, then the connection is shared and the IsShared property value is true. In addition, if the Web page is in shared personalization scope when a connection is added, the connection is also shared. Typically, when a user uses the <asp:connectionszone> user interface (UI) to add a connection, the page is in user personalization scope, so the connection is not shared and the IsShared property value is false.

The following code example demonstrates programmatic use of the IsShared property.

The code example has five parts:

  • A user control that enables you to change the Web Parts display mode on a page.

  • Source code for an interface and two WebPart controls acting as the provider and the consumer for a connection.

  • A Web page to host all the controls and run the code example.

  • An entry in the Web.config file that is required to run the example.

  • An explanation of how to run the example page.

The first part of this code example is the user control that enables users to change display modes on a Web page. Save the following source code to an .ascx file, giving it the file name that is assigned to the Src attribute of the Register directive for this user control, which is near the top of the hosting Web page. 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.

No code example is currently available or this language may not be supported.

The second part of the code example is the source code for the interface, and the consumer and provider controls. For the code example to run, you must compile this source code. You can compile it explicitly and put the resulting assembly in your Web site's Bin folder or the global assembly cache. Alternatively, you can put the source code in your site's App_Code folder, where it will be dynamically compiled at run time. This code example uses dynamic compilation. For a walkthrough that demonstrates how to compile, see Walkthrough: Developing and Using a Custom Web Server Control.

No code example is currently available or this language may not be supported.

The third part of the code example is the Web page. In the Button2_Click method, it checks the IsShared property of the existing connection and displays the result on the page.

No code example is currently available or this language may not be supported.

The fourth part of the code example is an entry in the Web.config file that is required for the user account that will be running the example to be able to edit the page in shared personalization scope. To enable this, you must have an entry in the Web.config file within the <system.web> section that looks like the following example.

<webParts>
  <personalization>
    <authorization>
      <allow users="UserAccount"
             roles="admin"
             verbs="enterSharedScope"/>
    </authorization>          
  </personalization>
</webParts>

After you load the page in a browser, use the Display Mode drop-down list control to switch the page to connect display mode. Click the Connect WebPart Controls button to form a connection. Next, click the Connection Details button to display whether the connection is shared. If you created the connection with the page in the default user personalization scope, the IsShared property value should be false for the connection.

On the verbs menu of one of the WebPart controls (indicated by the downward arrow in the title bar), click the connect verb. When the connection UI appears, click the Disconnect button to end the connection. Use the Display Mode control to return the page to browse mode.

In the Display Mode control, select the Shared option to switch the page into shared personalization scope. Follow the same steps as those above to create a connection, and again click the Connection Details button to display whether the connection is shared. In this case, the value of the IsShared property should be true.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Show: