Web User Controls (asp.net 1.1)

  • Thread starter Thread starter Stimp
  • Start date Start date
S

Stimp

I am using a web control stored in the root directory containing an
image like:

<IMG height="84" alt="" src="images/image1.gif" width="120" border="0">

This works fine on .aspx pages that are in the same directory as the
..ascx file, but when I call the user control from an .aspx page in a
subdirectory the image is not picked up (and a blank gap is left).


Do ascx files need to be stored in the same directory as the aspx files
that call them in order for images to be referenced correctly?

Thanks.
 
Stimp, that happens because the path is relative. use this notation

src="~/Images/logo.jpg"

hth

Jose
 
The path is relative to the page in which the control is hosted. In this
case that's bad.
Try this syntax (with the tilde~) to have it be relative to the app's root:

<IMG height="84" alt="" src="~/images/image1.gif" width="120" border="0"
runat="server">
 
Back
Top