Custom Attributes for Mobile Controls
All ASP.NET mobile controls allow you to set custom control attributes using theinterface of ASP.NET Web pages. This interface provides the methods and . Additionally, the class exposes a collection named .
Custom attributes can be used to specify additional attributes about a control and can be used in a device-specific adapter to adjust the control's behavior or rendering.
By default, the ability to set custom attributes on a control is disabled. There are two ways to enable custom attributes:
By setting an attribute of the <mobileControls> section in the Web.config file, as shown in the following code example:
<configuration> <system.web> ... <mobileControls allowCustomAttributes="True" /> ... </system.web> </configuration>
This setting affects the default of all pages in the application.
By setting theproperty of the class to true. This setting affects all controls on the page.
The wmlFormat attribute for the http://www.wapforum.org.control is sent to WML devices as the Format attribute of the WML <input> element. This is a custom attribute and is distinct from the first-class attributes of the control. However, before custom attributes will work, you must enable them. For a full listing of valid formats, see the WML specification, available through the Wireless Application Protocol Forum (WAP) at
The wmlFormat attribute overrides the NNN," the <input> element is limited to three numeric characters.property for the TextBox control. For example, if the wmlFormat attribute is set to "
With custom attributes turned on, typographic errors in property names can be mistaken for custom attributes. For example, if you incorrectly specify theproperty of a control as "Txet," the parser saves it as a custom attribute named "Txet" instead of raising an exception. As a precaution, custom attributes are disallowed by default.