Edytuj

Udostępnij za pośrednictwem


Image.ImageUrl Property

Definition

Gets or sets the URL that provides the path to an image to display in the Image control.

public:
 virtual property System::String ^ ImageUrl { System::String ^ get(); void set(System::String ^ value); };
[System.ComponentModel.Bindable(true)]
public virtual string ImageUrl { get; set; }
[<System.ComponentModel.Bindable(true)>]
member this.ImageUrl : string with get, set
Public Overridable Property ImageUrl As String

Property Value

The URL that provides the path to an image to display in the Image control.

Attributes

Examples

The following example demonstrates how to use the ImageUrl property to specify the location of the image to display in the Image control.

<%@ 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 the ImageUrl property to specify the URL of an image to display in the Image control. You can use a relative or an absolute URL. A relative URL relates the location of the image to the location of the Web page without specifying a complete path on the server. The path is relative to the location of the Web page. This makes it easier to move the entire site to another directory on the server without updating the code. An absolute URL provides the complete path, so moving the site to another directory requires that you update the code.

Applies to