WebPartMobileAdapter.Control property

Gets the Web Part that is being adapted.

Namespace:  Microsoft.SharePoint.WebPartPages
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)


Protected ReadOnly Property Control As WebPart
Dim value As WebPart

value = Me.Control
protected WebPart Control { get; }

Property value

Type: System.Web.UI.WebControls.WebParts.WebPart
The Web Part that is being adapted.


If the adapted Web Part is an Microsoft.SharePoint.WebPartPages.WebPart, it is cast to System.Web.UI.WebControls.WebParts.WebPart and returned.

Notes to inheritors

If you override CreateControlsForSummaryView(), CreateControlsForDetailView(), or some other method, and your logic requires access to the members of the Web Part that is being adapted that it does not inherit from System.Web.UI.WebControls.WebParts.WebPart, consider hiding Control in your derived class by declaring a Control property, using the new keyword. Your new property casts the Web Part that is being adapted back to its specific Web Part type. An example of doing this is below. For more information about hiding member (which is called ‘shadowing’ in Visual Basic) see Hiding through inheritance and Shadowing in Visual Basic.


The following is an example of hiding and replacing the Control property with a property that casts the Web Part back to its specific type.

protected new SomeWebPart Control
    get { return base.Control as SomeWebPart; }
Protected Shadows ReadOnly Property Control() As SomeWebPart
        Return TryCast(MyBase.Control, SomeWebPart)
    End Get
End Property

See also


WebPartMobileAdapter class

WebPartMobileAdapter members

Microsoft.SharePoint.WebPartPages namespace

Other resources Hiding through inheritance

Shadowing in Visual Basic