asp.net.ph

HyperLink.ImageUrl Property

System.Web.UI.WebControls Namespace   HyperLink Class


Sets or retrieves the path to an image to display for the hyperlink.

Syntax


Inline <asp:hyperlink imageurl = strUrl ... >
Script HyperLink.ImageUrl [ = strUrl ]

Property Value


strUrl String that specifies the path to the image to display for the hyperlink.

The property is read/write with no default value.

Remarks

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.

Example

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.

Custom Paging with AutoIncrement Data Model
Run Sample | View Source
DataGrid Columns Property
Run Sample | View Source
See Also

HyperLink Members   NavigateUrl   Text Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph