Image.AlternateText Property
Gets or sets the alternate text displayed in the Image control when the image is unavailable. Browsers that support the ToolTips feature display this text as a ToolTip.
Namespace: System.Web.UI.WebControls
Assembly: System.Web (in system.web.dll)
Image Members
System.Web.UI.WebControls Namespace
ImageUrl
GenerateEmptyAlternateText
Assembly: System.Web (in system.web.dll)
Syntax
Visual Basic (Declaration)
<LocalizableAttribute(True)> _ <BindableAttribute(True)> _ Public Overridable Property AlternateText As String
Visual Basic (Usage)
Dim instance As Image Dim value As String value = instance.AlternateText instance.AlternateText = value
C#
[LocalizableAttribute(true)] [BindableAttribute(true)] public virtual string AlternateText { get; set; }
C++
[LocalizableAttribute(true)] [BindableAttribute(true)] public: virtual property String^ AlternateText { String^ get (); void set (String^ value); }
J#
/** @property */ public String get_AlternateText () /** @property */ public void set_AlternateText (String value)
JScript
public function get AlternateText () : String public function set AlternateText (value : String)
XAML
Not applicable.
Property Value
The alternate text displayed in the Image control when the image is unavailable.Remarks
Use this property to specify the text to display if the image specified in the ImageUrl property is not available. In browsers that support the ToolTips feature, this text also displays as a ToolTip.
The value of this property, when set, can be saved automatically to a resource file by using a designer tool. For more information, see LocalizableAttribute and ASP.NET Globalization and Localization.
Example
The following example demonstrates how to use the AlternateText property to specify the alternate text to display for the image when the image is not available.
Visual Basic
<%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Image Example</title> </head> <body> <form id="form1" runat="server"> <h3>Image Example</h3> <asp:Image id="Image1" runat="server" AlternateText="Image text" ImageAlign="left" ImageUrl="images/image1.jpg"/> </form> </body> </html>
C#
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Image Example</title> </head> <body> <form id="form1" runat="server"> <h3>Image Example</h3> <asp:Image id="Image1" runat="server" AlternateText="Image text" ImageAlign="left" ImageUrl="images/image1.jpg"/> </form> </body> </html>
JScript
<%@ Page Language="JSCRIPT" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Image Example</title> </head> <body> <form id="form1" runat="server"> <h3>Image Example</h3> <asp:Image id="Image1" runat="server" AlternateText="Image text" ImageAlign="left" ImageUrl="images/image1.jpg"/> </form> </body> </html>
Platforms
Windows 98, Windows Server 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Version Information
.NET Framework
Supported in: 3.0, 2.0, 1.1, 1.0See Also
Reference
Image ClassImage Members
System.Web.UI.WebControls Namespace
ImageUrl
GenerateEmptyAlternateText