.NET Framework 类库
Image..::.ImageUrl 属性

更新:2007 年 11 月

获取或设置在 Image 控件中显示的图像的位置。

命名空间:  System.Web.UI.WebControls
程序集:  System.Web(在 System.Web.dll 中)

语法

Visual Basic(声明)
<BindableAttribute(True)> _
Public Overridable Property ImageUrl As String
Visual Basic (用法)
Dim instance As Image
Dim value As String

value = instance.ImageUrl

instance.ImageUrl = value
C#
[BindableAttribute(true)]
public virtual string ImageUrl { get; set; }
Visual C++
[BindableAttribute(true)]
public:
virtual property String^ ImageUrl {
    String^ get ();
    void set (String^ value);
}
J#
/** @property */
/** @attribute BindableAttribute(true) */
public String get_ImageUrl()
/** @property */
/** @attribute BindableAttribute(true) */
public  void set_ImageUrl(String value)
JScript
public function get ImageUrl () : String
public function set ImageUrl (value : String)
ASP.NET
<asp:Image ImageUrl="String" />

属性值

类型:System..::.String

Image 控件中显示的图像的位置。

备注

使用 ImageUrl 属性指定在 Image 控件中显示的图像的 URL。可以使用相对 URL 或绝对 URL。相对 URL 使图像的位置与网页的位置相关联,而不指定服务器上的完整路径。该路径相对于网页的位置。由于不必更新代码,这使得将整个站点移动到服务器上的其他目录变得更加容易。绝对 URL 提供完整路径,因此将站点移到其他目录时需要更新代码。

TopicLocation
如何:向 Web 窗体页添加 Image Web 服务器控件生成 ASP .NET Web 应用程序
如何:向 Web 窗体页添加 Image Web 服务器控件 (Visual Studio)在 Visual Studio 中构建 ASP .NET Web 应用程序
如何:向 Web 窗体页添加 Image Web 服务器控件 (Visual Studio)在 Visual Studio 中生成 ASP .NET Web 应用程序
如何:向 Web 窗体页添加 ImageButton Web 服务器控件生成 ASP .NET Web 应用程序
如何:向 Web 窗体页添加 ImageButton Web 服务器控件 (Visual Studio)在 Visual Studio 中构建 ASP .NET Web 应用程序
如何:向 Web 窗体页添加 ImageButton Web 服务器控件 (Visual Studio)在 Visual Studio 中生成 ASP .NET Web 应用程序
如何:向 Web 窗体页添加 ImageMap Web 服务器控件生成 ASP .NET Web 应用程序
如何:向网页添加 ImageMap Web 服务器控件在 Visual Studio 中生成 ASP .NET Web 应用程序
如何:向网页添加 ImageMap Web 服务器控件 (Visual Studio)在 Visual Studio 中构建 ASP .NET Web 应用程序
示例

下面的示例说明如何使用 ImageUrl 属性指定在 Image 控件中显示的图像的位置。

Visual Basic
<%@ 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>

C#
<%@ 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>

JScript
<%@ 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
另请参见

参考

其他资源

标记 :


Page view tracker