Compartilhar via


WebPart.CanRunAt Method

NOTE: This API is now obsolete.

Returns a value that indicates where the implementation of a connection interface can run.

Namespace:  Microsoft.SharePoint.WebPartPages
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No

Syntax

'Declaration
<ObsoleteAttribute("Use ConnectionProvider or ConnectionConsumer attribute to create ConnectionPoint instead.")> _
Public Overridable Function CanRunAt As ConnectionRunAt
'Usage
Dim instance As WebPart
Dim returnValue As ConnectionRunAt

returnValue = instance.CanRunAt()
[ObsoleteAttribute("Use ConnectionProvider or ConnectionConsumer attribute to create ConnectionPoint instead.")]
public virtual ConnectionRunAt CanRunAt()

Return Value

Type: Microsoft.SharePoint.WebPartPages.Communication.ConnectionRunAt
A Microsoft.SharePoint.WebPartPages.Communication.ConnectionRunAt enumeration value.

Remarks

When developing a connectable Web Part, you must override the CanRunAt method to return the appropriate value for the implementation of a connection interface. The CanRunAt method should return a ConnectionRunAt enumeration that indicates whether implementation for the connection interface can run on the server, the client, both, or not at all (ConnectionRunAt.None). The default behavior of this method is to throw an exception that returns Strings.CommunicationMethodNotImplementedError. This method is called before the inherited System.Web.UI.Control class's PreRender event and after the Load event.

Examples

The following code example shows how to override the CanRunAt method to indicate that the connection interface can run only on the server.

To see this method in a fuller context, see Walkthrough: Creating Connectable SharePoint Web Parts

Public Overrides Function CanRunAt() As ConnectionRunAt
   ' This Web Part can run on the server.
   Return ConnectionRunAt.Server
End Function
public override ConnectionRunAt CanRunAt()
{
    // This Web Part can run on the server.
    return ConnectionRunAt.Server;
}

See Also

Reference

WebPart Class

WebPart Members

Microsoft.SharePoint.WebPartPages Namespace