Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

You receive a run-time error message when you try to access the properties that are programmatically exposed by the IWebPart interface


View products that this article applies to.

Symptoms

Consider the following scenario. You have a Microsoft ASP.NET 2.0-based application. You try to use properties of an ASP.NET server control that is located in a WebPartZone control. You use any one of the System.Web.UI.Webcontrols.WebParts.IWebPart properties on the ASP.NET server control. In this scenario, you receive the following run-time error message:
Type ControlName does not have a public property named PropertyName.
You may experience this issue when one of the following conditions is true:
  • You try to access the properties that are programmatically exposed by the IWebPart interface.
  • You declare the properties on the control when the control is in a WebPartZone control.

↑ Back to the top


Cause

This issue may occur when any one of the following conditions is true:
  • The ASP.NET server control does not implement the IAttributeAccessor interface.
  • The ASP.NET server control does not inherit the IAttributeAccessor interface from another control that implements the interface.
The IAttributeAccessor interface is required to support expando properties, and all the IWebPart properties of the ASP.NET server control are expando properties. Expando properties are properties that can be added and removed dynamically at run time.

↑ Back to the top


Workaround

To work around this issue, you must wrap the control that does not implement the IAttributeAccessor interface in a user control. Then add the user control to a WebPartZone control. Because the System.Web.UI.UserControl class implements the IAttributeAccessor interface and the IAttributeAccessor interface allows for expando properties, you can then use the IWebPart properties on the control that is contained in the user control.

↑ Back to the top


More information

To determine when a control supports the use of the IWebPart properties, check to see whether the control has the IAttributeAccessor interface implemented somewhere in its inheritance.

The following ASP.NET 2.0 controls do not implement the IAttributeAccessor interface:
  • BasePartialCachingControl
  • AccessDataSource
  • CompleteWizardStep
  • Content
  • ContentPlaceHolder
  • Control
  • CreateUserWizardStep
  • DataBoundLiteralControl
  • DataSourceControl
  • DesignerDataBoundLiteralControl
  • ErrorFormatterPage
  • HiddenField
  • HierarchicalDataSourceControl
  • LabelLiteral
  • Literal
  • LiteralControl
  • Localize
  • LoginView
  • MenuItemTemplateContainer
  • MultiView
  • NonParentingControl
  • ObjectDataSource
  • Page
  • PartialCachingControl
  • PlaceHolder
  • ProxyWebPartManager
  • Repeater
  • RepeaterItem
  • ResourceBasedLiteralControl
  • SiteMapDataSource
  • SqlDataSource
  • StaticPartialCachingControl
  • Substitution
  • TemplateControl
  • TemplatedWizardStep
  • View
  • WebPartManager
  • WizardStep
  • WizardStepBase
  • Xml
  • XmlDataSource

Steps to reproduce the issue

  1. Start Microsoft Visual Studio 2005.
  2. On the File menu, click New Web Site.
  3. In the Templates box, click ASP.NET Web Site under Visual Studio installed templates, type DriveLetter:\Path\KB911715 in the Location box, and then click OK.
  4. Add a WebPartManager control to the designer surface.
  5. Add a WebPartZone control to the designer surface.
  6. Add a Repeater control to the WebPartZone control.
  7. On the designer surface, click Source, and then replace the Repeater control with the following code example.
    <asp:Repeater ID="Repeater1" runat="server" Title="myTitle">
                    </asp:Repeater>
  8. On the File menu, click Save Default.aspx, and then click Exit to close Visual Studio 2005.

    When you try to open the Default.aspx page, you receive the error message that is mentioned in the "Symptoms" section.

↑ Back to the top


References

For more information about the .NET Framework Class Library IWebPart properties, visit the following Microsoft Developer Network (MSDN) Web site:

↑ Back to the top


Keywords: KB911715, kbprb, kbtshoot

↑ Back to the top

Article Info
Article ID : 911715
Revision : 3
Created on : 2/14/2006
Published on : 2/14/2006
Exists online : False
Views : 328