System.Web.UI.WebControls Namespace HyperLink Class
Sets or retrieves the path to an image to display for the hyperlink.
Inline |
<asp:hyperlink imageurl = strUrl ... > |
Script |
HyperLink.ImageUrl [ = strUrl ] |
strUrl |
String that specifies the path to the image to display for the hyperlink. |
The property is read/write with no default value.
Use this property to specify the path to the image file to display for the HyperLink control. If the image file is in the same directory as the Web page that uses it, simply specify the file name. Otherwise, include the path to the file.
The path can be absolute or relative to the directory where the Web page is located. You can use the relative path symbol [ ~/ ] to refer to the application root or virtual directory. If the path is relative, it is automatically converted to an absolute path when the HyperLink control is rendered on the browser.
This allows images, as well as other files that a Web page may be dependent on, such as user controls ( .ascx files ), to be more portable.
For example, assuming the application virtual directory is aspxtreme, the path specified in the following declaration
<asp:hyperlink imageurl = "~/shared/myGraphic.png" runat = "server" >
will resolve to the absolute path
<asp:hyperlink imageurl = "/shared/myGraphic.png" runat = "server">
In certain cases, as when hyperlinks are used within templated controls, the ImageUrl property is usually obtained dynamically from a data source.
The following example shows how to declaratively set the ImageUrl property of a HyperLink control at design time.
<asp:hyperlink runat = "server"
text = "Simply awesome"
imageurl = "~/shared/aspxtreme.jpg"
navigateurl = "~/index.aspx" />
The following examples demonstrate how to dynamically bind the ImageUrl property of HyperLink controls defined within templates.
HyperLink Members NavigateUrl Text