473,406 Members | 2,707 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,406 software developers and data experts.

Web User Controls (asp.net 1.1)

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

fiddlewidawiddum
Feb 22 '06 #1
2 889
Stimp, that happens because the path is relative. use this notation

src="~/Images/logo.jpg"

hth

Jose

"Stimp" <re*@spumco.com> wrote in message
news:sl****************@carbon.redbrick.dcu.ie...
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.
--

fiddlewidawiddum

Feb 22 '06 #2
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">

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Stimp" <re*@spumco.com> wrote in message
news:sl****************@carbon.redbrick.dcu.ie...
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.
--

fiddlewidawiddum

Feb 22 '06 #3

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

Similar topics

10
by: Alphonse Giambrone | last post by:
I have a web form with 2 user controls on it (UC1 and UC2). Each control has a bound datagrid with textboxes in the footer to add a new row. There are also requiredfieldvalidators in each footer....
6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
3
by: Chad A. Beckner | last post by:
Hey everyone, Ok. I have a "template and skin" setup on the beginnings of a new portal site. In this site, there are going to be many applications, which will be store underneath the "master"...
1
by: Josh | last post by:
I am trying to move some of my more common controls into user controls. However, I seem to have problems maintaining state of databound controls that are contained within user controls. On...
6
by: Steve Booth | last post by:
I have a web form with a button and a placeholder, the button adds a user control to the placeholder (and removes any existing controls). The user control contains a single button. I have done all...
4
by: Mark | last post by:
I am setting up an asp.net site using the Ektron CMS. Every page in the site uses the same basic template, with the look of the page changing via CSS and an id on the body. The id is shared by all...
2
by: Scott | last post by:
I'm using a master page (mp_TableMaint.aspx) with one Content area (ID: Content1). Content1 contains several usercontrols, which are hidden. The goal is to show the correct control based on the...
8
by: fernandezr | last post by:
I would like to use a user control as a template inside a repeater. Some of the fields in the control should be hidden depending on whether or not there is data. I'm still a ASP .Net newbie so the...
8
by: mark.norgate | last post by:
I've run into a few problems trying to use generics for user controls (classes derived from UserControl). I'm using the Web Application model rather than the Web Site model. The first problem...
2
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
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: 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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.