MobileCapabilities Class


ASP.NET Mobile Controls
PreferredImageMime Property

Returns the MIME type of the type of image content preferred by the device. The default value is image/gif.

public virtual string PreferredImageMime {
   get
}

Example

The following example demonstrates how to use the PreferredImageMime property to specify the type of preferred image for the device.

[Visual Basic]
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
     
     Dim currentCapabilities As System.Web.Mobile.MobileCapabilities = CType(Request.Browser, System.Web.Mobile.MobileCapabilities)
     Dim prefImage As String = currentCapabilities.PreferredImageMime
     
     If (prefImage.Equals("image/gif"))
        'Set the path of an image to the color image.
        Image1.ImageUrl = "Image.gif"
     Else If (prefImage.Equals("image/vnd.wap.wbmp"))
        'Set the path of the image to a .wbmp image.
         Image1.ImageUrl = "Image.wbmp"
        
     End If
   
End Sub

[C#]

public void Page_Load(Object sender, EventArgs e)
{
   MobileCapabilities currentCapabilities
      = (MobileCapabilities)Request.Browser;
   String prefImage = currentCapabilities.PreferredImageMime;

   if (prefImage.Equals("image/gif"))
   {
      // Set the path of an image to the color image.
      Image1.ImageUrl = "image.gif";
   }
   else if
     (prefImage.Equals("image/vnd.wap.wbmp"))
   {
      // Set the path of the image to a .wbmp image.
      Image1.ImageUrl = "image.wbmp";
   }
}

See Also

Applies to: MobileCapabilities Class

Page view tracker