WebPartConnection::ToString Method
Overrides the inherited ToString method and returns a short type name for the connection object.
Assembly: System.Web (in System.Web.dll)
Return Value
Type: System::StringA string that contains the short (unqualified) type name of a WebPartConnection.
This method is used mostly for convenience by control designers. It improves how connection objects appear in Design view by using the shorter type name, as opposed to a fully qualified type name. However, the method can be called at any point in your code where you want to know the type name of a connection object.
The following code example demonstrates how to call the ToString method to return the short type name of a WebPartConnection object.
The code example has three parts:
Source code for an interface and two WebPart controls acting as the provider and the consumer for a connection.
A Web page to host the controls and run the code example.
An explanation of how to run the example page.
The first 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.
The second part of the code example is the Web page. Near the top is a Register directive that refers to the source code for the two dynamically compiled WebPart controls. The static connection is declared within the <StaticConnections> element on the page. The Button1_Click method calls the ToString method to write the type name of the connection to a label.
Load the page in a browser. The static connection is already created. Enter some text in the provider control, and note that the text is displayed in the consumer control. Click the Connection Details button to execute the ToString method.
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.