April 21, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Write Custom WebParts for SharePoint 2007, Page 2

  • July 17, 2006
  • By Sahil Malik, Sahil Malik
  • Send Email »
  • More Articles »

Using the WebPart

Go to the site of your choice. I created a site called "TestSite" using the Blank Template included in SharePoint. Once at that site, click on Site Actions --> Edit Page as shown below:

Your page will prompt you to add new WebParts as shown below:



Click here for a larger image.

In my case, I have two WebPartZones. Depending upon the template you selected, your exact UI may look different. Click the "Add a WebPart" button on any one of the WebPart zones. You will see the "Add Web Parts" dialog, which simply shows you a list of possible WebParts you could add to your page.

Under Miscellaneous, you should see the SimpleWebPart. Check the checkbox, and click "Add" (see Figure 4).

Figure 4: Add SimpleWebPart

You now should see the WebPart you wrote running under SharePoint, as shown below:



Click here for a larger image.

Now, you can play with this WebPart a bit. Click the "Edit" menu, and select "Modify Shared Web Part" as shown here:

You will notice that an "EditorZone" pops up. Modify the values as shown below:

Figure 5: Modify the SimpleWebPart Values

Click OK, and then click "Exit Edit Mode" on the top, right-hand side of the page (this may be specific to the template your site is based on) as shown here:

You should see your fully customized WebPart running inside MOSS 2007. The following is an action shot of all your hard work:

Congratulations! You have just written a WebPart for MOSS 2007, deployed it, and used it successfully on a SharePoint Web page.

Microsoft Office and SharePoint Server 2007 Integration

This tutorial demonstrated how to write a simple WebPart and then host and use it in MOSS 2007. Your real world applications will probably require more complicated WebParts, but to keep the WebPart simple, the demonstration left out some details. For instance, SharePoint by default comes in a very locked-down, secure mode. When writing WebParts for SharePoint, you need to have a good understanding of how code-access security works.

About the Author

Sahil Malik (www.winsmarts.com) has worked for a number of top-notch clients in Microsoft technologies ranging from DOS to .NET. He is the author of Pro ADO.NET 2.0 and co-author of Pro ADO.NET with VB.NET 1.1. Sahil is currently also working on a multimedia series on ADO.NET 2.0 for Keystone Learning. For his community involvement, contributions, and speaking, he has also been awarded the Microsoft MVP award.





Page 2 of 2



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel