Image In User Control

  • Thread starter Thread starter RN1
  • Start date Start date
R

RN1

A user control has an image & a few Labels. When I view the ASPX page
that uses this user control in my local machine, the image can be seen
but when I upload the ASPX page & the ASCX page to my remote server,
the ASPX page shows the Labels but it doesn't show the image.
Strangely the source code of the ASPX page includes the image code.

What could the problem be?

Thanks,

Ron
 
Hi,

Check the source of the image...
a relative url will work okay in every case if you have the image in
your project...
perhaps you are working with absolute URL...

 Best of luck

When the image wasn't getting rendered, I was using

<table background="\Images\Stars.gif">

When I changed it to

<table background="Images\Stars.gif">

the image gets rendered. Why so?

Thanks,

Ron
 
When the image wasn't getting rendered, I was using

<table background="\Images\Stars.gif">

When I changed it to

<table background="Images\Stars.gif">

the image gets rendered. Why so?

Thanks,

Ron

If you prefix your path with a \, you indicate that the path is
relative to the site's root. If the path is relative to the page,
don't use the first \. For instance, if your site has this structure :

Default.aspx
SomeFolder/
SomeFolder/MyPage.aspx
SomeFolder/Pics/
SomeFolder/Pics/mypic.gif

...and your table is in the "MyPage.aspx", specifying this path for
the image :

\Pics\mypic.gif

...would look for a "Pics" folder at the root of the site. As there
isn't one, nothing happens. Whereas this:

Pics\mypic.gif

...would look for a "Pics" folder at the same level as the containg
page, that is, inside "SomeFolder".

(also, as you're dealing with Urls and not the filesystem, you should
use forward slashes instead of backslashes. The framework translates
for you, but it's just a good habit to have).

Michel
 
Back
Top