Share via


AllowCustomAttributes Property

Sets or returns whether or not controls on the page can have custom attributes defined. The default value is the value of the allowCustomAttributes attribute of the <mobilecontrols> section of the Web.config file.

public bool AllowCustomAttributes {
   get,
   set
}

Remarks

In addition to the IAttributeAccessor interface, the ASP.NET page framework provides a CustomAttributes dictionary that allows you to specify additional attributes, enable or disable custom attributing, or adjust a control's behavior or rendering.

To enable or disable custom attributing, you can either set the AllowCustomAttributes property to true, or you can set the allowCustomAttributes attribute of the <mobileControls> section of web.config to true.

Note   With custom attributes turned on, typographic errors in property names can be interpreted as custom attributes. For example, if a developer incorrectly specifies the Text property of a control as "Txet", the parser will save it as a custom attribute called "Txet", rather than raise an exception. Custom attributes are turned off by default as a precaution.

Example

The following example demonstrates how to use the AllowCustomAttributes property to enable the custom accesskey attribute on the Command control.

<Mobile:Form runat=server id=frmTemplate >
<mobile:Command runat="server" id="cmd1" Text="No AccessKey" 
      accesskey="1" onClick="onClick">
   <DeviceSpecific>
      <Choice Filter="IsAccesskey" Text="1 is AccessKey"/>
   </DeviceSpecific>
 </mobile:Command>
</Mobile:Form>

//Web.Config
<configuration>
<system.web>
   <deviceFilters>
      <filter name="IsAccesskey" compare="supportsAccesskeyAttribute" 
         argument="true" />        
   </deviceFilters>
   <sessionState cookieless="true" />
   <httpRuntime useFullyQualifiedRedirectUrl="true"/>
   <mobileControls allowCustomAttributes="True" />
</system.web>
</configuration>

See Also

Custom Attributes

Applies to: MobilePage Class