Share via


AlternateText Property

Sets or returns the alternate text to display when an image is not available for the device. The default value is an empty string ("").

public string AlternateText {
   get,
   set
}

Remarks

The alternate text appears in browsers that do not support images.

Example

The following example demonstrates how to use the AlternateText property to display .

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

     ' Programmatically add an image URL.
     Image1.ImageUrl = "myimage.gif"

     'Browsers that do not support an image format will show alternate text.
     Image1.AlternateText = "Image not Supported"
     Image1.NavigateURL = "https://www.microsoft.com"

    End Sub
[C#]

private void Page_Load(object sender, System.EventArgs e)
{
   // Programmatically add an image URL.
   Image1.ImageUrl = "myimage.gif";

   // Browsers that do not support an image format
   // will show alternate text.
   Image1.AlternateText = "Image not Supported";
   Image1.NavigateURL = "https://www.microsoft.com";
}  

See Also

Image Control

Applies to: Image Class