Writing Your Own Mobile Web Controls 

Writing your own mobile controls provides the greatest measure of flexibility. When you develop mobile controls, you must adhere to the following basic guidelines:

  • Write your mobile control so that it inherits from the MobileControl base class and not from the ASP.NET Control class. The MobileControl base class inherits all the capability from the ASP.NET Control class that is required for developing controls for mobile devices. However, to reuse the logic from an ASP.NET server control, you can use containment to include the control in a mobile control.

  • Write your control so that the code itself is device-independent.

  • Write device-specific adapters for each device type that requires a different type of rendering for the control.

  • Design reusable code so that other developers can inherit properties and methods from your control.

For a detailed example of writing your own control, see the ASP.NET Mobile Quickstart tutorials.

Custom Persistence

ASP.NET server controls can implement customized persistence formats (syntax) by using their own control builder. You can enable this by creating a control builder class and then adding a ControlBuilder attribute to the class. ASP.NET uses control builder objects when a page is parsed and compiled.

The MobileControl base class has its own control builder, the MobileControlBuilder class. In all mobile controls that implement their own control builder, the builder must inherit from the MobileControlBuilder class. The following table lists control classes that implement their own control builder.

See Also