HtmlImage.Alt Property

 

Gets or sets the alternative caption the browser displays if an image is unavailable or currently downloading and not yet finished.

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

public string Alt { get; set; }

Property Value

Type: System.String

A string that contains the alternative caption for the browser to use when the image is unavailable.

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.

The following code example demonstrates how to use the Alt property to specify the caption to display when the image specified by the Src property is unavailable.

<%@ Page Language="C#" AutoEventWireup="True" %>
 <!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>HtmlImage Example</title>
</head>

 <body>

    <form id="form1" runat="server">

       <h3>HtmlImage Example</h3>

       <img id ="Image1"
            src="Image1.jpg"
            alt="Image 1"
            runat="server"
            style="width:500; height:226; border:5; text-align:center" />

    </form>

 </body>
 </html>

.NET Framework
Available since 1.1
Return to top
Show: