473,385 Members | 1,661 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Image path problem in user control

I have a user control called Footer.ascx, in which a background image
is inserted like so:

<div id="footerdiv" style="background-image:url('Images/
mybackground.jpg'); background-position:center; background-repeat:no-
repeat;" <!-- My footer content goes here. --</div>

This Footer.ascx is under a folder called /UserControls (the leading
forward slash indicates the root of the web application, same below).

The /Images folder is directly under the root just like /UserControls.

If I use this user control in pages directly under the root such as /
Page1.aspx, /Page2.aspx, the background image shows up nicely.

But if I try to use it in web pages under another folder such as /
SystemAdmin/AdminPage1.aspx, the background image does not show up.

Apparently, when I use this Footer.ascx user control in pages directly
under the web root, IIS is able to locate the path Images/
background.jpg from the root.

But, if I use it in pages under /SystemAdmin/, IIS wouldn't be able to
locate the relative path Images/background.jpg because there is no
such thing under /SystemAdmin.

Now, do I have to create another user control Footer2.aspx for /
SystemAdmin folder just because of the path problem? How can I use
the same user control in different folders and have the background
image shows up nicely?

I tried ~/Images/mybackground.jpg, but because that div and style
setting is client side, it does not work. Is it possible to use
Server.MapPath inside the style setting? I tried, but could not get
it to work.

Please share your insights. Thanks a lot!
Mar 31 '08 #1
1 2820
On Mar 31, 10:47 am, gnewsgroup <gnewsgr...@gmail.comwrote:
I have a user control called Footer.ascx, in which a background image
is inserted like so:

<div id="footerdiv" style="background-image:url('Images/
mybackground.jpg'); background-position:center; background-repeat:no-
repeat;" <!-- My footer content goes here. --</div>

This Footer.ascx is under a folder called /UserControls (the leading
forward slash indicates the root of the web application, same below).

The /Images folder is directly under the root just like /UserControls.

If I use this user control in pages directly under the root such as /
Page1.aspx, /Page2.aspx, the background image shows up nicely.

But if I try to use it in web pages under another folder such as /
SystemAdmin/AdminPage1.aspx, the background image does not show up.

Apparently, when I use this Footer.ascx user control in pages directly
under the web root, IIS is able to locate the path Images/
background.jpg from the root.

But, if I use it in pages under /SystemAdmin/, IIS wouldn't be able to
locate the relative path Images/background.jpg because there is no
such thing under /SystemAdmin.

Now, do I have to create another user control Footer2.aspx for /
SystemAdmin folder just because of the path problem? How can I use
the same user control in different folders and have the background
image shows up nicely?

I tried ~/Images/mybackground.jpg, but because that div and style
setting is client side, it does not work. Is it possible to use
Server.MapPath inside the style setting? I tried, but could not get
it to work.

Please share your insights. Thanks a lot!
No one has a clue? Or is it the case that I did not make it clear?

OK, simply put, if I insert an image using stylesheet in a user
control, how to use this user control in web pages which sit in
different folders with different depths from the root?
Mar 31 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
0
by: amita | last post by:
hi, 1.I want to show a image file of type '.tif' in the browser window; for that I'm writting as ASP code page. 2.This '.tif' type image can be shown better with 'Kodak Image Control'. 3.To...
6
by: Arnold | last post by:
Hey there, I've browsed for some fixes to this but only found a couple of similar posts, which didn't solve my problem. I'm wondering how to refresh an image control in a form after a user...
6
by: Arnold | last post by:
Hi there, I've looked at numerous posts out there but have yet to find a solution to this. I have an image control on a main form that shows a linked jpeg thumbnail. Image controls are also on...
7
by: Scott Schluer | last post by:
Is there a way to use the Image class to convert a color photo (GIF or JPEG) to a B&W photo? Thanks, Scott
5
by: Diomatas | last post by:
Hi I ve got a class with some public properties and one of them is of type image. I use these properties in a propertygrid. When the user press the little button into the propertygrid, an open...
3
by: Thomas Satzinger | last post by:
Hallo., i just encounterd a strange thing which i cannot resolve. I am saving a bitmap created in memory to the asp temp folder (asp.net 2.0) this works fine, and i donīt want to create an...
0
by: gnewsgroup | last post by:
I have a user control called Footer.ascx, in which a background image is inserted like so: <div id="footerdiv" style="background-image:url('Images/ mybackground.jpg');...
3
by: premprakashbhati | last post by:
hi, good evening.. i am going to upload an image in a web form .....for that iam using HTML input(file) control and one web control button i.e., Upload_Button() here is the code ...its work fine...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.