This documentation is archived and is not being maintained.

Image.GenerateEmptyAlternateText Property

Gets or sets a value indicating whether the control generates an alternate text attribute for an empty string value.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)

public virtual bool GenerateEmptyAlternateText { get; set; }
<asp:Image GenerateEmptyAlternateText="True|False" />

Property Value

Type: System.Boolean
true if the control generates the alternate text attribute for an empty string value; otherwise, false. The default is false.

By default, when the AlternateText property is not set, the Image control does not include the alt attribute to specify the alternate text in the control rendering. Set the GenerateEmptyAlternateText property to true to always include the alternate text attribute in rendered output for the Image control.

The XHTML document type definition requires the alt attribute on image controls. However, accessibility best practices recommend that image controls that do not convey information relevant to the context of the Web page should not specify an alt attribute. You can meet both XHTML and accessibility requirements by setting the GenerateEmptyAlternateText property to true.

Walkthrough: Creating an Accessible Web ApplicationBuilding ASP .NET Web Applications in Visual Studio

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.