Working with Web Parts in ASP.NET 2.0
Takeaway: Web Parts are now available to all ASP.NET developers with version 2.0. These controls allow developers to easily build dynamic, customizable user interfaces with plenty of options for the users.
Web Parts are one of the more interesting features in ASP.NET 2.0. They are a new family of controls available for building dynamic Web interfaces that allow users to easily customize or personalize a page. Web Parts are components that users can display, hide, or move. This week, I provide an overview of the new feature.
Dividing a page
Web Parts will be familiar to Microsoft SharePoint developers and users since they are a standard feature of the SharePoint environment. Web Parts are a software component for controlling portions of a page. In ASP.NET 2.0, Web Parts provide menus that users can use to control component behavior like hiding, maximizing, or editing it.
A key concept to understand when dealing with Web Parts is the division of a Web page. Basically, a page is divided into regions called zones. The layout of Web Parts may be controlled via zones in ASP.NET.
The hierarchy of controls
ASP.NET 2.0 includes numerous controls that may be used to utilize Web Parts in a Web application. The main one is WebPartManager, and it is required to use Web Parts. This control is not visible to the end user, but it manages a page's personalization state and coordinates communication between parts and zones.
Every page that uses the Web Part Control Set must have a WebPartManager control on it. A WebPartManager control has the following syntax:
<asp:WebPartManager ID="WebPartManagerID" runat="server">
</asp:WebPartManager>
The next control in the hierarchy is the WebPartZone; it allows you to specify certain areas of a Web Form. It serves as the primary control in a Web Parts control set for hosting controls. The WebPartZone is the second control (or multiple controls for multiple zones) to add to a page when taking advantage of Web Parts. A WebPartZone has the following syntax:
<asp:WebPartZone ID="WebPartZoneName" runat="server" HeaderText="Example">
</asp:WebPartZone>
The WebPartZone control is used to define a region (or zone) of a page, and it may contain other controls as the example in Listing A demonstrates by including an ASP.NET button control within a WebPartZone (the sample includes the full page source including the WebPartManager control).
The example includes three zones that are presented on the page via an HTML table (the second zone includes the button control). While this is a very simple example, you can place any ASP.NET server control within these zones. The WebPartManager and WebPartZone controls are the foundation, but there are numerous other controls available.
Working with Visual Studio
One of the simplest ways to use controls is through the Visual Studio development environment. The Toolbox area within Visual Studio (when developing Web Forms) includes a WebParts category that contains the various controls available to utilize Web Parts in an application.
I have covered the WebPartManager and WebPartZone controls, but there are more available. Two of the more important controls include the following:
- CatalogZone: Serves as the primary control in the Web Parts control set for hosting ASP.NET server controls of type CatalogPart on a Web page. A catalog is simply a list of Web Parts or other server controls that are visible when a page is in catalog display mode.
- ConnectionZone: Allows you to set properties of a connection and enable/disable the connection. Using this control requires the Web Parts to be configured to use connections. The ProxyWebPartManager can be used to utilize static connections.
There are numerous additional controls available, but they are beyond the scope of this article. In addition, you may develop your own custom controls as well. These controls may be used to control various aspects of a page utilizing Web Parts.
Arranging Web Parts
Web Parts provide various modes to control user interaction. These include the following:
- Browse: This is the default mode; it is the standard way Web pages are used.
- Design: Allows users to drag and drop Web Parts within a page. This mode is always available.
- Edit: Allows users to drag and drop Web Parts, as well as select Edit to control various aspects of a control. There are various Edit-based controls available to provide this functionality. This is an extension of the Design mode.
- Catalog: Allows users to add additional controls via a defined list. The CatalogZone control provides this functionality.
- Connect: Allows users to manually establish connections between controls. This feature is available via the ConnectionZone control.
The controls available with ASP.NET allow you to utilize these modes in your application depending upon the requirement.
Another presentation option
Web Parts have been a standard feature of the SharePoint environment for some time, but they are now available to all ASP.NET developers with version 2.0. These controls allow you to easily build dynamic, customizable user interfaces with plenty of options for the users. There are various controls available to integrate Web Parts in your application, but you can develop your own custom controls as well. For more details about Web Parts, check out this article on MSDN.
Miss a column?
Check out the .NET Archive, and catch up on the most recent editions of Tony Patton's column.
Tony Patton began his professional career as an application developer earning Java, VB, Lotus, and XML certifications to bolster his knowledge.
Print/View all Posts Comments on this article
|
|
|
|
|
|
|
|
White Papers, Webcasts, and Downloads
- Building the Virtualized Enterprise with VMware Iinfrastructure VMware VMware virtualization software has been adopted by over 120,000 enterprise ... Download Now
- The True Costs of Virtual Server Solutions VMware Discover ways to streamline and simplify your assessment of the total acquisition costs of a server virtualization environment. Download Now
- The Scalable Enterprise: VMware ESX Server on the Dell PowerEdge 6650 Dell This paper introduces the server virtualization software, VMware ESX ... Download Now
- Why Isn't Server Virtualization Saving Us More? A Few Small Changes May Dramatically Increase Your Efficiency VMware Ever wonder why your company isn't saving more from its server virtualization? Making a few small changes could dramatically increase your efficiency. Download Now
- Email Security and Archiving - Clearer in the Cloud Google The time is NOW for businesses and organizations of all sizes to implement ... Download Now
Article Categories
- Security
- Security Solutions, IT Locksmith
- Networking and Communications
- E-mail Administration NetNote, Cisco Routers and Switches
- CIO and IT Management
- Project Management, CIO Issues, Strategies that Scale
- Desktops, Laptops & OS
- Windows 2000 Professional, Microsoft Word, Microsoft Excel, Microsoft Access, Windows XP,
- Data Management
- Oracle, SQL Server
- Servers
- Windows NT, Linux NetNote, Windows Server 2003
- Career Development
- Geek Trivia
- Software/Web Development
- Web Development Zone, Visual Basic, .NET


