Microsoft KB Archive/911715

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

Article ID: 911715

Article Last Modified on 2/14/2006

-

APPLIES TO


 * Microsoft ASP.NET 2.0

-





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  does not have a public property named.

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.



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.



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.



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
 Start Microsoft Visual Studio 2005. On the File menu, click New Web Site. In the Templates box, click ASP.NET Web Site under Visual Studio installed templates, type :\Path\KB911715 in the Location box, and then click OK. Add a WebPartManager control to the designer surface. Add a WebPartZone control to the designer surface. Add a Repeater control to the WebPartZone control.</li>  On the designer surface, click Source, and then replace the Repeater control with the following code example. <asp:Repeater ID=&quot;Repeater1&quot; runat=&quot;server&quot; Title=&quot;myTitle&quot;> </asp:Repeater> </li> 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 &quot;Symptoms&quot; section.</li></ol>

<div class="references_section">