|
<- Read Part 1 of the Article
Add the Web Part to the Web Part Gallery
The next step is to add the web part to the web part gallery. Adding the web part to the web part gallery will make the web part available in the SharePoint site when you want to use it.
Open the Windows SharePoint Services V3.0 site. Navigate to the Site Setting Page by clicking Site Action -> Site Settings

Figure 8: Site Action options
The Site Settings page will display as in Figure 9.

Figure 9: Site Settings Page
Click the Web Parts link under the Gallery section.
The Web Part Gallery page will display as in Figure 10.

Figure 10: Web Part Gallery page
In Windows SharePoint Services V2.0, the only way that you could add a web part to the SharePoint site was by using the web part DWP file. In WSS V3.0 there are two types of file supported. They are DWP and WEBPART files. You can see that both file types are supported in Figure 10 in the Web Part Gallery page. The webpart file type is used when you add an ASP.NET 2.0 web part to the web part gallery. The dwp file type is supported when you add a WSS V3.0 web part to the web part gallery. You will be adding a webpart file to support your code example, because you are working on an ASP.NET 2.0 web part.
You have two options to add a webpart file to the web part gallery.
You can upload the web part file by clicking the upload button,
or you can click the New button on the tool bar.
When you click the New button, SharePoint will read all the web parts in the Safe Control list in the SharePoint web.config file and make them available to the user. In this case, the webpart file will be generated automatically for you. Your ASPNETWebPartHello will be available in the Add Web part list as displayed in figure 11.

Figure 11: ASPNETWebPartHello in Web Part Gallery: New Web Parts page
Select the check box in front of ASPNETWebPartHello and click the Populate Gallery
button to add the web part to the web part gallery as displayed in Figure 12.

Figure 12: Hello.webpart web part in the web part Gallery
Web Part Gallery Options
You can click the Edit icon in front of the Hello.webpart to update its details as displayed in Figure 13.

Figure 13: ASPNETWebPartHello web part properties
Update the Webpart Details
You can change the Name and the Title and add a Description. The web parts can be grouped together for easy access. I am creating a new group called Litware in the group section. I can navigate to the Litware group to find the Hello web part when I want to add it to the SharePoint page.
View Webpart File in XML Format
You can look at the webpart file structure by clicking the View XML tab on the top toolbar.
It will open the webpart file in an XML format in the Internet browser as displayed in Figure 14.

Figure 14: Hello.webpart file in XML format
Export the Webpart File
You can export the webpart file to a different location by clicking the Export option on the top toolbar. This is useful when you want to move the web part from one environment to another. This will give you the option to save the webpart file as displayed in figure 15.

Figure 15: Exporting the Hello.webpart file
Web Part Display Form
You can get details about the Hello.webpart file by clicking Hello on the top breadcrumb.

Figure 16: Breadcrumb trail
This will open the details page on the Hello web part as displayed in Figure 17.

Figure 17: Hello.webpart details page.
You can edit, delete, manage permissions, check out/in and set up alerts for the web part. Figure 18 displays how it looks when you select the alert option.

Figure 18: Setting up an alert for the Hello.webpart
Web Part Preview Page
You can preview the web part functionality from the Web Part Gallery page. Navigate to the Web Part Gallery page and click on the Hello.webpart link or the XML icon in front. The Web Part Gallery Preview Page will be displayed as in Figure 19.

Figure 19: Web Part Gallery: Web Part Preview page displaying Hello.webpart
Adding the Web Part to the SharePoint Site
You have now successfully added the Hello web part to the web part gallery.
Now you will add it to the SharePoint site.
Open the SharePoint site and select Edit Page from the
Site Actions menu as displayed in Figure 20:

Figure 20: Edit Page option from Site Actions menu
This will open the page in edit mode.
Select a web part zone and click the Add a Web Part link.
This will open the Add Web Part page as displayed in Figure 21.

Figure 21: Add Web Part page
You created the Litware group to identify the Hello web part easily.
Select the Hello web part and click the Add button to add it to the SharePoint site.
The final Hello web part will appear in the SharePoint site as displayed in Figure 22.

Figure 22: Hello Web Part in SharePoint Site
About the Author
Gayan Peiris (MVP, MCSD, MCAD, MIT, BComp) is an expert in architecting and designing SharePoint
Portals and Windows SharePoint Services solutions. He has written many articles, reviews and columns for various
online publications. Gayan is a frequent speaker at Microsoft developer conferences on SharePoint technology.
He has been a leading SharePoint advocate since 2001 and is president of
the Canberra SharePoint User Group.
Gayan been presented with
MVP award for Microsoft Office SharePoint Portal Server.
Gayan works as a Technical Architect/Principal Consultant for Unique World Pty Ltd
in Canberra, Australia. He can be reached at
http://www.gayanpeiris.com and
http://gpeiris.blogspot.com.
|