This documentation is archived and is not being maintained.

HtmlInputImage.Alt Property

Gets or sets the alternative text that the browser displays if the image is unavailable or has not been downloaded.

[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

The alternative text for the specified image.

Remarks

Use the Alt property to specify the text to display when the specified image is not available or has not been downloaded. You can also use this property to programmatically determine the specified alternative text.

In browsers that support the ToolTip feature, this text also displays as a ToolTip for the HtmlInputImage control.

Example

[Visual Basic, JScript] The following example demonstrates how to use the Alt property to specify the alternate text to display when the image is not available.

[Visual Basic] 
<%@ Page Language="VB" AutoEventWireup="True" %>

<html>
   <script language="VB" runat=server>

      Sub SubmitBtn_Click(ByVal Source As Object, ByVal E as ImageClickEventArgs)
         Message.InnerHtml = "The Submit Button was clicked!"
      End Sub
 
      Sub ClearBtn_Click(ByVal Source As Object, ByVal E as ImageClickEventArgs)
         Message.InnerHtml = "The Clear Button was clicked!"
      End Sub

   </script>
 
   <body>

      <form method=post runat=server>

         <input type=image
                alt="Submit Button" 
                src="Submit.jpg" 
                OnServerClick="SubmitBtn_Click" 
                runat=server>

         <input type=image 
                alt="Clear Button" 
                src="Clear.jpg" 
                OnServerClick="ClearBtn_Click" 
                runat=server>
 
         <h1> <span id="Message" runat=server></span>
         </h1>

      </form>

   </body>

</html>


[JScript] 
<%@ Page Language="JScript" AutoEventWireup="True" %>

<html>
   <script language="JSCRIPT" runat=server>

      function SubmitBtn_Click(source : Object, e : ImageClickEventArgs){
         Message.InnerHtml = "The Submit Button was clicked!"
      }
 
      function ClearBtn_Click(source : Object, e : ImageClickEventArgs){
         Message.InnerHtml = "The Clear Button was clicked!"
      }

   </script>
 
   <body>

      <form method=post runat=server>

         <input type=image
                alt="Submit Button" 
                src="Submit.jpg" 
                OnServerClick="SubmitBtn_Click" 
                runat=server>

         <input type=image 
                alt="Clear Button" 
                src="Clear.jpg" 
                OnServerClick="ClearBtn_Click" 
                runat=server>
 
         <h1> <span id="Message" runat=server></span>
         </h1>

      </form>

   </body>

</html>

[C#, C++] No example is available for C# or C++. To view a Visual Basic or JScript example, click the Language Filter button Language Filter 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

HtmlInputImage Class | HtmlInputImage Members | System.Web.UI.HtmlControls Namespace

Show: