Focus on Microsoft Technologies - Tutorials, Articles, Code Samples.

Saturday, September 02, 2006

Work Web Part Magic Inside of ASP.NET

Microsoft released SharePoint to the market back in 2000/2001 and, in doing so, began a shift in perception about how Web applications are built. The change was slow at first and has yet to take over the way we build applications completely; however, the change has started.

Rather than the old way of building page after page of copied content, this change moves toward a development model for Websites that focuses on reusable, connectable, and user-configurable components that are assembled quickly in different ways to create the solutions that business users need. In the Sharepoint world, these reusable components are called Web parts.

Now, ASP.NET 2.0 has integrated Web parts and the core concepts behind it: the idea that you build applications from components and not as page after page of similar functionality. This core approach to software development has the potential to accelerate your business by allowing users to assemble their own software solutions—solutions that normally they would not be able to create on their own.

In this article you'll learn the core concepts behind an ASP.NET 2.0 Web part, how this structure relates to (and is better than) Windows SharePoint Services 2.0 (and Microsoft Office SharePoint Portal Server 2003), and how to build your own Web part page.

What is a Web Part?
At its most basic level a Web part is a Web control (or server control if you prefer) that supports an extra set of methods and properties. These methods and properties are designed to allow you to easily manipulate configuration data and appearance/UI elements programmatically.

In SharePoint a Web part had to derive from the Microsoft.SharePoint.WebParts.WebPart class. In ASP.NET 2.0 the key requirement is that the Web control that you want to use as a Web part implements the System.Web.UI.WebControls.WebParts.IWebPart. If you derive from System.Web.UI.WebControls.WebParts.WebPart the IWebPart interface is already supported for you. So you can build ASP.NET 2.0 Web parts just as you would have built a SharePoint Web part—by deriving from a base class.

ASP.NET 2.0 has a cool twist: It allows you to use any Web control as a Web part even if the Web control does not support the IWebPart interface natively. The ASP.NET 2.0 framework wraps the Web control in a generic wrapper and uses that wrapper to expose the necessary interface.

Continue with complate article

Post a Comment