更新:2007 年 11 月
获取或设置在 Image 控件中显示的图像的位置。
命名空间:
System.Web.UI.WebControls 程序集:
System.Web(在 System.Web.dll 中)
<BindableAttribute(True)> _
Public Overridable Property ImageUrl As String
Dim instance As Image
Dim value As String
value = instance.ImageUrl
instance.ImageUrl = value
[BindableAttribute(true)]
public virtual string ImageUrl { get; set; }
[BindableAttribute(true)]
public:
virtual property String^ ImageUrl {
String^ get ();
void set (String^ value);
}
/** @property */
/** @attribute BindableAttribute(true) */
public String get_ImageUrl()
/** @property */
/** @attribute BindableAttribute(true) */
public void set_ImageUrl(String value)
public function get ImageUrl () : String
public function set ImageUrl (value : String)
<asp:Image ImageUrl="String" />
使用 ImageUrl 属性指定在 Image 控件中显示的图像的 URL。可以使用相对 URL 或绝对 URL。相对 URL 使图像的位置与网页的位置相关联,而不指定服务器上的完整路径。该路径相对于网页的位置。由于不必更新代码,这使得将整个站点移动到服务器上的其他目录变得更加容易。绝对 URL 提供完整路径,因此将站点移到其他目录时需要更新代码。
下面的示例说明如何使用 ImageUrl 属性指定在 Image 控件中显示的图像的位置。
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<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="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<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="JSCRIPT" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<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>
Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
.NET Framework 和 .NET Compact Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。
.NET Framework
受以下版本支持:3.5、3.0、2.0、1.1、1.0
参考
其他资源