This topic has not yet been rated - Rate this topic

AlphaImage Class

Use the AlphaImage Web control to render PNG images in Microsoft Internet Explorer.

System.Object
  System.Web.UI.Control
    Microsoft.SharePoint.WebControls.SPControl
      Microsoft.SharePoint.WebControls.AlphaImage
        Microsoft.SharePoint.WebControls.ViewIcon

Namespace:  Microsoft.SharePoint.WebControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class AlphaImage : SPControl

The AlphaImage Web control uses ECMAScript (JScript, JavaScript) to change the filter style for a PNG image. This allows Microsoft Internet Explorer to render transparency for the PNG image.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
AlphaImage
Description 

The Microsoft.SharePoint.WebControls.AlphaImage class inherits from the Microsoft.SharePoint.WebControls.SPControl class which serves as the base server control for SharePoint WebControls. The AlphaImage class provides a control that allows you to conditionally display transparent PNGs taking into account browser limitations, which is problematic with antiquated browsers such as Internet Explorer Version 6.

The control works by performing modest browser tests by using SPUtility.IEVersion, along with other minimal examinations. If the browser is found to be unsupported for appropriate display, then the standard HTML image tag is not used for rendering, however a supported JavaScript method supplied by the init.js file is instead leveraged. This supplies the displayPNGImage method, which will add the image to a temporary array. In the body load wrapper script, the b method will call this array which loops through rendering each image out with a standard CSS alpha filter to fully support transparent PNGs.

Usage Scenario

The AlphaImage class certainly has heavy internal representation, notably in classes such as Microsoft.SharePoint.WebControls.ViewIcon class. However, it is exceedingly accommodating when building WebParts that include transparent images and the client browser requirements are not consistently established. 

Since the AlphaImage is a customary WebControl, it can purely be instantiated and then added to the current instance control collection. This assumes that all the appropriate JavaScript intiatives are in place. 

Adam Buenz
SharePoint Foundation MVP - http://www.sharepointsecurity.com