Proprietà PreferredImageMime

Restituisce il tipo MIME del tipo di contenuto dell'immagine più adatto al dispositivo. Il valore predefinito è image/gif.

public virtual string PreferredImageMime {
   get
}

Esempio

Nell'esempio che segue viene illustrato come utilizzare la proprietà PreferredImageMime per specificare il tipo di immagine più adatto al dispositivo.

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";
   }
}

Vedere anche

Si applica a: classe MobileCapabilities