WebPartMobileAdapter.Control property

Gets the Web Part that is being adapted.

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

Syntax

'Declaration
Protected ReadOnly Property Control As WebPart
    Get
'Usage
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.

Remarks

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 3.7.1.2 Hiding through inheritance and Shadowing in Visual Basic.

Examples

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
    Get
        Return TryCast(MyBase.Control, SomeWebPart)
    End Get
End Property

See also

Reference

WebPartMobileAdapter class

WebPartMobileAdapter members

Microsoft.SharePoint.WebPartPages namespace

Other resources

3.7.1.2 Hiding through inheritance

Shadowing in Visual Basic