Web User Controls (asp.net 1.1)

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.
 
J

Jose Rodriguez

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

src="~/Images/logo.jpg"

hth

Jose
 
S

Steve C. Orr [MVP, MCSD]

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">
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top