Image.AlternateText Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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.
public:
virtual property System::String ^ AlternateText { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.Bindable(true)]
public virtual string AlternateText { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.AlternateText : string with get, set
Public Overridable Property AlternateText As String
Property Value
The alternate text displayed in the Image control when the image is unavailable.
- Attributes
Examples
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.
<%@ 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>
<%@ 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>
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.
Applies to
See also
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈