Creating the Web Part
We now have the Web Part project set up with the necessary references, so let’s create the Web Part.
1. In Solution Explorer, right-click on the project name, and select Add New Item.
2. Select the Web Part file template from the Code category, name it
NavigationWebPart.cs
, and click Open.
Note
If you choose Consumer/Provider Web Part
or Tool Part
, several interfaces will be implemented to enable Web Part communication. For the navigation Web Part, we can use the generic Web Part
template as it does not need to communicate with other Web Parts.
You should now see the NavigationWebPart.cs
file in Solution Explorer and the code should be open in code view. As you will see from the generated code, a Web Part inherits from Microsoft.SharePoint.WebPartPages.WebPart
, which in turn inherits from System.Web.UI.Control
.
The NavigationWebPart
class has attributes that are used by the Web Part infrastructure and Visual Studio .NET. Please remove the attribute DefaultProperty...