Database Search Solution
(New Version) Search Control
Free ASP.NET Controls
ASP.NET Media Player Control
Flash Video Player Control
ASP.NET Telecommute Jobs
Free IP Location Lookup
Test .Net Regular Expressions
CSS/Table/DIV Page Layouts
Article Sites Master List
.NET Windows Forms
General .NET Framework
Accepting Credit Cards
Support Mobile Devices in ASP.NET (Advances Topics)
In the last article, I explained the basics of supporting mobile devices in ASP.NET. After reading that article, I hope you would have grasp the basics of writing mobile pages and using mobile controls for developing mobile specific web sites.
After reading this article, the reader must be having knowledge of:
How to customize mobile pages by Device Type
In traditional ASP.NET pages, the same role is played by BrowserCapabilities class. Request.Browser is an object of this class and can be used in the following way:
Using this knowledge, Can you guess how to use Request.Broswer in mobile pages? Code bellow shows its use.
TypeDescriptor object is used to collect complete list of properties by using GetProperties method. In this case, all properties returned by the Request.Browser are collected by this object and assigned to "p". The List would display all the properties which Request.Browser returns. This is done by binding this list to "p". The PropertyDescriptorCollection contains a property Name to access the name of each target object's properties. To bind the list control to "p", DataTextField property has been named as Name.
In short, Request.Browser enlists many properties of the device which is stored in the object of PropertyDescriptorCollection. To bind this object with the list control, you have to name the DataTextField property of control as Name.
Listing above is useful when you want to analyze many capabilities of device. If you want to check a capability such as VBScript support, the HasCapability of Request.Browser can be used in the following way:
There is another method which relies on defining device filters in web.config file and later using this file. I assume the method described above suffices developers need for checking device capabilities.
Using Cascading Style sheets in mobile pages
By using StyleSheet Control and mobile web control attributes, custom styles can be applied easily in ASP.NET. Below are some mobile web controls:
The StyleSheetControl contains many style sets. Each set can specify the Foreground color, name, size etc of the text. When in a form, StyleReference is assigned a particular style set; this means the text in that form would be displayed using the defined font specifications in Style set. To experience a concrete example, see code listing bellow:
Developing User Friendly Mobile Pages:
In any system, be its software or else; usability of the system is key. Increasing the usability of your product should be a main design consideration.
First thing is, you should understand the ViewState control. By enabling the ViewState property, values of other controls are preserved and displayed when the same page is rendered again. For example, if you have enabled ViewState for all controls in user registration page, all the values of controls (e.g. value for User name text field, Gender's check box) would be preserved if the page shows some input error (like user name already taken) and is rendered again. All the values that you have entered before would be there in their respective fields. All the values of controls are stored in one hidden field which is for ViewState and is named as _VIEWSTATE. It would be something like:
An example is:
In short, Use HiddenVariables collection of Form class instead of ViewState in session.
There are many things which are common across diversity of mobiles. Every mobile device contains a Back button and scroller to scroll through the contents of the page. Alphanumeric input is difficult in almost all mobile devices. User friendly sites can be made using knowledge of common features.
Developing a website with multiple small pages rather than one lengthy page is good option. Users would not mind pressing Back button to select and access other link but scrolling down to browse through a page seems a hectic task. So, divide your homepage in logical divisions.
Some mobile devices do not render graphics. Try avoiding the graphics which are essential for understanding the page. Text-Only mobile phones would skip graphics.