Export (0) Print
Expand All

Image.ImageUrl Property

Gets or sets the location of an image to display in the Image control.

[Visual Basic]
Public Overridable Property ImageUrl As String
[C#]
public virtual string ImageUrl {get; set;}
[C++]
public: __property virtual String* get_ImageUrl();
public: __property virtual void set_ImageUrl(String*);
[JScript]
public function get ImageUrl() : String;
public function set ImageUrl(String);

Property Value

The location of an image to display in the Image control.

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.

Example

[Visual Basic, C#, JScript] The following example demonstrates how to use the ImageUrl property to specify the location of the image to display in the Image control.

[Visual Basic] 
<%@ Page Language="VB" %>
<html>
<head>

</head>
 
<body>

   <form 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#" %>
<html>
<head>

</head>
 
<body>

   <form 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" %>
<html>
<head>

</head>
 
<body>

   <form 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++] No example is available for C++. To view a Visual Basic, C#, or JScript example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

Image Class | Image Members | System.Web.UI.WebControls Namespace

Show:
© 2014 Microsoft