WebPart constructor

Initializes the class for use by an inherited class instance. This constructor can only be called by an inherited class.

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

Syntax

'Declaration
Protected Sub New
'Usage

Dim instance As New WebPart()
protected WebPart()

Remarks

The WebPart constructor initializes default values for properties where the defaults differ from those inherited from WebPart. In particular, the constructor initializes the ExportMode property to All and the HelpMode property to Modeless.

Examples

The following example shows a Web Part control that inherits from the WebPart class but changes the value of one property in the constructor of the derived control.

using System;
using System.Web.UI;
using System.Web.UI.WebControls;

using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;

namespace MyWebParts
{
    public class BasicSharepointWebPart : WebPart
    {
        public BasicSharepointWebPart() : base()
        {
            this.ExportMode = System.Web.UI.WebControls.WebParts.WebPartExportMode.NonSensitiveData;
        }
    }
}
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls

Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.WebControls
Imports Microsoft.SharePoint.WebPartPages

Namespace MyWebParts

    Public Class BasicSharepointWebPart
        Inherits WebPart

        Public Sub New()
          MyBase.New()
            Me.ExportMode = WebParts.WebPartExportMode.NonSensitiveData

        End Sub

    End Class

End Namespace

See also

Reference

WebPart class

WebPart members

Microsoft.SharePoint.WebPartPages namespace

ExportMode

HelpMode