Defines common user interface (UI) properties used by ASP.NET System.Web.UI.WebControls.WebParts.WebPart controls.

See Also: IWebPart Members


public interface IWebPart


The System.Web.UI.WebControls.WebParts.IWebPart interface provides several UI-oriented properties that enhance the user experience of working with System.Web.UI.WebControls.WebParts.WebPart controls. When you create controls that derive from the base System.Web.UI.WebControls.WebParts.WebPart class, you get an implementation of all the properties in the System.Web.UI.WebControls.WebParts.IWebPart interface, because the System.Web.UI.WebControls.WebParts.WebPart base class implements this interface.

You can use existing user controls, ASP.NET controls, or custom server controls that do not inherit from the System.Web.UI.WebControls.WebParts.WebPart class as part of a Web Parts application, and they can also use these UI-oriented properties declared by the System.Web.UI.WebControls.WebParts.IWebPart interface. If you place existing server controls in a System.Web.UI.WebControls.WebParts.WebPartZoneBase zone, at run time they are wrapped with a System.Web.UI.WebControls.WebParts.GenericWebPart object. Because the System.Web.UI.WebControls.WebParts.GenericWebPart class inherits from the System.Web.UI.WebControls.WebParts.WebPart base class, it enables existing server controls to act as true System.Web.UI.WebControls.WebParts.WebPart controls and it adds to them the properties of the System.Web.UI.WebControls.WebParts.IWebPart interface.

If you place server controls that are not System.Web.UI.WebControls.WebParts.WebPart controls in zones, they can use the System.Web.UI.WebControls.WebParts.IWebPart properties at run time, and you can also declare values for those properties on server controls in the markup of the page (in page persistence format). However, because these properties are only available to the server controls at run time, design-time coding features such as IntelliSense do not recognize System.Web.UI.WebControls.WebParts.IWebPart properties that are declared on server controls. Declared properties on these controls still work when you load the page, but Microsoft Visual Studio does not recognize the properties as valid at design time. If you want to add the System.Web.UI.WebControls.WebParts.IWebPart properties to existing server and user controls to enhance the design-time user experience, you can implement the System.Web.UI.WebControls.WebParts.IWebPart interface in a server control.

Perhaps the main reason to implement the System.Web.UI.WebControls.WebParts.IWebPart interface is for controls that do not support the use of expando (custom) properties. Expando properties are strings that can be added to a class dynamically as a property, by means of the System.Web.UI.IAttributeAccessor interface. Controls that implement this interface, including the System.Web.UI.WebControls.WebControl class and its children, can use expando properties. Therefore, all ASP.NET server controls, custom controls that derive from them, Web user controls, and System.Web.UI.WebControls.WebParts.WebPart controls support the use of expando properties. But custom controls that inherit directly from the base System.Web.UI.Control class do not support expando properties. Thus, if you declare these controls within a System.Web.UI.WebControls.WebParts.WebPartZone, you will not be able to declare the common System.Web.UI.WebControls.WebParts.IWebPart properties on the controls, properties such as IWebPart.Title and IWebPart.Description. If you want to use these properties with such controls, you must implement the System.Web.UI.WebControls.WebParts.IWebPart interface.


Namespace: System.Web.UI.WebControls.WebParts
Assembly: System.Web (in System.Web.dll)
Assembly Versions:
Since: .NET 2.0