O'Reilly logo

ASP.NET 2.0 Website Programming Problem - Design - Solution by Marco Bellinaso

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

10.3. Solution

In this last section you'll learn how to integrate most of what you've learned about Web Parts into the existing site. You'll follow the same order of the examples proposed in the "Design" section, i.e., starting from implementing the Web Parts, and then ending with modifying the current master page by adding Web Part zones, the WebPartManager, the editors, and the catalogs.

10.3.1. Creating the Web Parts

Because you already have the user controls that you want to insert into the Web Part catalog, all you need to do here is add the proper attributes to the controls' properties, and implement the IWebPart interface. You start from this second point: Implement the interface in a new class called BaseWebPart (found in ~/App_Code/BaseWebPart.cs) that also inherits from UserControl:

public class BaseWebPart : UserControl, IWebPart { private string _catalogIconImageUrl = ""; public string CatalogIconImageUrl { get { return _catalogIconImageUrl; } set { _catalogIconImageUrl = value; } } private string _description = ""; public string Description { get { return _description; } set { _description = value; } } protected string _subTitle = ""; public string Subtitle { get { return _subTitle; } set { _subTitle = value; } } protected string _title = ""; public string Title { get { return _title; } set { _title = value; } } private string _titleIconImageUrl = ""; public string TitleIconImageUrl { get { return _titleIconImageUrl; } set { _titleIconImageUrl = value; } } private ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required