Export (0) Print
Expand All

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)
Available in Sandboxed Solutions: No

protected WebPart()

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.

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;
        }
    }
}

Community Additions

ADD
Show:
© 2014 Microsoft