WebPartConnection::ToString Method ()

 

Overrides the inherited ToString method and returns a short type name for the connection object.

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

public:
virtual String^ ToString() override

Return Value

Type: System::String^

A 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.

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

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.

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

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.

.NET Framework
Available since 2.0
Return to top
Show: