HtmlImage.Alt Property
Gets or sets the alternative caption the browser displays if an image is unavailable or currently downloading and not yet finished.
[Visual Basic] Public Property Alt As String [C#] public string Alt {get; set;} [C++] public: __property String* get_Alt(); public: __property void set_Alt(String*); [JScript] public function get Alt() : String; public function set Alt(String);
Property Value
A string that contains the alternative caption for the browser to use when the image is unavailable.
Remarks
Use this property to specify the caption displayed when the image specified by the Src property is unavailable. On newer browsers, this caption also appears as a ToolTip.
Example
[Visual Basic, C#, JScript] The following example demonstrates how to use the Alt property to specify the caption to display when the image specified by the Src property is unavailable.
[Visual Basic] <%@ Page Language="VB" AutoEventWireup="True" %> <html> <head> </head> <body> <form runat="server"> <h3>HtmlImage Example</h3> <img id ="Image1" Src="image1.jpg" Width="500" Height="226" Alt="Image 1" Border="5" Align="center" runat=server/> </form> </body> </html> [C#] <%@ Page Language="C#" AutoEventWireup="True" %> <html> <head> </head> <body> <form runat="server"> <h3>HtmlImage Example</h3> <img id ="Image1" Src="image1.jpg" Width="500" Height="226" Alt="Image 1" Border="5" Align="center" runat=server/> </form> </body> </html> [JScript] <%@ Page Language="JScript" AutoEventWireup="True" %> <html> <head> </head> <body> <form runat="server"> <h3>HtmlImage Example</h3> <img id ="Image1" Src="image1.jpg" Width="500" Height="226" Alt="Image 1" Border="5" Align="center" runat=server/> </form> </body> </html>
[C++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also
HtmlImage Class | HtmlImage Members | System.Web.UI.HtmlControls Namespace | Src