473,396 Members | 1,892 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,396 software developers and data experts.

Driving me nuts...

It seems all of the sudden that user controls that
contain images are referencing image sources relative to
the document that I drop the control on. This obviously
does not work beacuase the image source is relative to
the user control, not necessarily the form. Can anyone
tell me why this would be the case?
Nov 17 '05 #1
12 1583
FWIW, this drives me nuts too!

This is how I do it for asp image, after dropping the control on the page
(or user control) I change the ImageUrl to something like
"~/'images/mypicture.jpg"

For an IMG html control I use src="<%=ResolveUrl("~/image/mypicture.jpg")%>"

The drawback to both of these is you don't get to see the actual image in
design mode, only the place marker.

HTH
Brian W

"Marty" <an*******@discussions.microsoft.com> wrote in message
news:00****************************@phx.gbl...
It seems all of the sudden that user controls that
contain images are referencing image sources relative to
the document that I drop the control on. This obviously
does not work beacuase the image source is relative to
the user control, not necessarily the form. Can anyone
tell me why this would be the case?

Nov 17 '05 #2
Marty,

I'm a bit confused. The URL to the image will have to be relative to the
Webform onto which your user control is placed. If not, the image link
will be broken.

Jim Cheshire [MSFT]
Developer Support
ASP.NET
ja******@online.microsoft.com

This post is provided as-is with no warranties and confers no rights.

--------------------
Content-Class: urn:content-classes:message
From: "Marty" <an*******@discussions.microsoft.com>
Sender: "Marty" <an*******@discussions.microsoft.com>
Subject: Driving me nuts...
Date: Mon, 10 Nov 2003 11:07:37 -0800
Lines: 6
Message-ID: <00****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Thread-Index: AcOnvefxXWxzEBR1RRmi3tV9aszCgw==
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Newsgroups: microsoft.public.dotnet.framework.aspnet
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:189810
NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

It seems all of the sudden that user controls that
contain images are referencing image sources relative to
the document that I drop the control on. This obviously
does not work beacuase the image source is relative to
the user control, not necessarily the form. Can anyone
tell me why this would be the case?


Nov 17 '05 #3
This is exactly the problem

When placing an image control on a UserControl the path assigned to the
image will be relative to the user control which is not necessarily the same
as the webform the user control is placed on.

Take the following example:

I have a folder/structure like this

root \+
Default.aspx
+- images\
mypicture.jpg
+- controls
myheader.ascx
+- help\
about.aspx

if I place an image control on myheader.ascx and use the designer to assign
the image, the designer assigns ../images/mypicture.jpg to the ImageUrl
attribute.

When I place myheader.ascx on Default.aspx (which reside in the root) and
run the app the link to mypicture.jpg is broken because
.../images/mypicture.jpg is not the correct relative path in the context of
Default.aspx.

Now, if I place myheader.ascx on about.aspx (residing in help directory) the
link is un-broken because the relative path for about.aspc is correct.

Clear as mud, right?!?! ;-)

I actually brought this very topic up several months ago in this or the IDE
NG.
Brian W


"Jim Cheshire [MSFT]" <ja******@online.microsoft.com> wrote in message
news:cd*************@cpmsftngxa06.phx.gbl...
Marty,

I'm a bit confused. The URL to the image will have to be relative to the
Webform onto which your user control is placed. If not, the image link
will be broken.

Jim Cheshire [MSFT]
Developer Support
ASP.NET
ja******@online.microsoft.com

This post is provided as-is with no warranties and confers no rights.

--------------------
Content-Class: urn:content-classes:message
From: "Marty" <an*******@discussions.microsoft.com>
Sender: "Marty" <an*******@discussions.microsoft.com>
Subject: Driving me nuts...
Date: Mon, 10 Nov 2003 11:07:37 -0800
Lines: 6
Message-ID: <00****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Thread-Index: AcOnvefxXWxzEBR1RRmi3tV9aszCgw==
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Newsgroups: microsoft.public.dotnet.framework.aspnet
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:189810NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

It seems all of the sudden that user controls that
contain images are referencing image sources relative to
the document that I drop the control on. This obviously
does not work beacuase the image source is relative to
the user control, not necessarily the form. Can anyone
tell me why this would be the case?

Nov 17 '05 #4
Thanks everyone. I've taken all the feedback and
formulated a few scenarious which now seem to be working
OK.

--------------------------

When using objects that support runat=server, use ~/ to
indicate "virtual root":

<a runat=server href="~/Forms/main.aspx"></a>

When using controls that do not support runat=server
(such as TD to set its background) use Page.ResolveURL:

<TD background="<%=Page.ResolveUrl("~/Images/fadeBG.jpg")
%>" height="5"></TD>

When using javascript for control attributes:

imgHome.Attributes.Add("onMouseOver", "this.src='" &
Page.ResolveUrl("~/Images/btn_home_dn.gif") & "';")
Nov 17 '05 #5
Brian,

Let me have a look into this. I'll post back to this thread ASAP.

Jim Cheshire [MSFT]
Developer Support
ASP.NET
ja******@online.microsoft.com

This post is provided as-is with no warranties and confers no rights.

--------------------
From: "Brian W" <brianw@gold_death_2_spam_rush.com>
References: <00****************************@phx.gbl> <cd*************@cpmsftngxa06.phx.gbl>Subject: Re: Driving me nuts...
Date: Mon, 10 Nov 2003 12:15:20 -0800
Lines: 89
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <e7**************@TK2MSFTNGP12.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: dsl-107.goldrush.com 206.171.170.107
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGXA06.phx.gbl!TK2MSFT NGXA05.phx.gbl!TK2MSFTNGP0
8.phx.gbl!TK2MSFTNGP12.phx.gblXref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:189838
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

This is exactly the problem

When placing an image control on a UserControl the path assigned to the
image will be relative to the user control which is not necessarily the sameas the webform the user control is placed on.

Take the following example:

I have a folder/structure like this

root \+
Default.aspx
+- images\
mypicture.jpg
+- controls
myheader.ascx
+- help\
about.aspx

if I place an image control on myheader.ascx and use the designer to assign
the image, the designer assigns ../images/mypicture.jpg to the ImageUrl
attribute.

When I place myheader.ascx on Default.aspx (which reside in the root) and
run the app the link to mypicture.jpg is broken because
../images/mypicture.jpg is not the correct relative path in the context of
Default.aspx.

Now, if I place myheader.ascx on about.aspx (residing in help directory) thelink is un-broken because the relative path for about.aspc is correct.

Clear as mud, right?!?! ;-)

I actually brought this very topic up several months ago in this or the IDE
NG.
Brian W


"Jim Cheshire [MSFT]" <ja******@online.microsoft.com> wrote in message
news:cd*************@cpmsftngxa06.phx.gbl...
Marty,

I'm a bit confused. The URL to the image will have to be relative to the
Webform onto which your user control is placed. If not, the image link
will be broken.

Jim Cheshire [MSFT]
Developer Support
ASP.NET
ja******@online.microsoft.com

This post is provided as-is with no warranties and confers no rights.

--------------------
>Content-Class: urn:content-classes:message
>From: "Marty" <an*******@discussions.microsoft.com>
>Sender: "Marty" <an*******@discussions.microsoft.com>
>Subject: Driving me nuts...
>Date: Mon, 10 Nov 2003 11:07:37 -0800
>Lines: 6
>Message-ID: <00****************************@phx.gbl>
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="iso-8859-1"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>Thread-Index: AcOnvefxXWxzEBR1RRmi3tV9aszCgw==
>X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
>Newsgroups: microsoft.public.dotnet.framework.aspnet
>Path: cpmsftngxa06.phx.gbl
>Xref: cpmsftngxa06.phx.gblmicrosoft.public.dotnet.framework.aspnet:189810 >NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>
>It seems all of the sudden that user controls that
>contain images are referencing image sources relative to
>the document that I drop the control on. This obviously
>does not work beacuase the image source is relative to
>the user control, not necessarily the form. Can anyone
>tell me why this would be the case?
>



Nov 17 '05 #6
For reference, see this thread started December of last year in this very NG

http://groups.google.com/groups?hl=e...40TK2MSFTNGP09
Brian W
"Jim Cheshire [MSFT]" <ja******@online.microsoft.com> wrote in message
news:SI****************@cpmsftngxa06.phx.gbl...
Brian,

Let me have a look into this. I'll post back to this thread ASAP.

Jim Cheshire [MSFT]
Developer Support
ASP.NET
ja******@online.microsoft.com

This post is provided as-is with no warranties and confers no rights.

--------------------
From: "Brian W" <brianw@gold_death_2_spam_rush.com>
References: <00****************************@phx.gbl> <cd*************@cpmsftngxa06.phx.gbl>
Subject: Re: Driving me nuts...
Date: Mon, 10 Nov 2003 12:15:20 -0800
Lines: 89
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <e7**************@TK2MSFTNGP12.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: dsl-107.goldrush.com 206.171.170.107
Path:

cpmsftngxa06.phx.gbl!TK2MSFTNGXA06.phx.gbl!TK2MSFT NGXA05.phx.gbl!TK2MSFTNGP0 8.phx.gbl!TK2MSFTNGP12.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:189838X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

This is exactly the problem

When placing an image control on a UserControl the path assigned to the
image will be relative to the user control which is not necessarily the

same
as the webform the user control is placed on.

Take the following example:

I have a folder/structure like this

root \+
Default.aspx
+- images\
mypicture.jpg
+- controls
myheader.ascx
+- help\
about.aspx

if I place an image control on myheader.ascx and use the designer to assignthe image, the designer assigns ../images/mypicture.jpg to the ImageUrl
attribute.

When I place myheader.ascx on Default.aspx (which reside in the root) and
run the app the link to mypicture.jpg is broken because
../images/mypicture.jpg is not the correct relative path in the context ofDefault.aspx.

Now, if I place myheader.ascx on about.aspx (residing in help directory)

the
link is un-broken because the relative path for about.aspc is correct.

Clear as mud, right?!?! ;-)

I actually brought this very topic up several months ago in this or the IDENG.
Brian W


"Jim Cheshire [MSFT]" <ja******@online.microsoft.com> wrote in message
news:cd*************@cpmsftngxa06.phx.gbl...
Marty,

I'm a bit confused. The URL to the image will have to be relative to the Webform onto which your user control is placed. If not, the image link
will be broken.

Jim Cheshire [MSFT]
Developer Support
ASP.NET
ja******@online.microsoft.com

This post is provided as-is with no warranties and confers no rights.

--------------------
>Content-Class: urn:content-classes:message
>From: "Marty" <an*******@discussions.microsoft.com>
>Sender: "Marty" <an*******@discussions.microsoft.com>
>Subject: Driving me nuts...
>Date: Mon, 10 Nov 2003 11:07:37 -0800
>Lines: 6
>Message-ID: <00****************************@phx.gbl>
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="iso-8859-1"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>Thread-Index: AcOnvefxXWxzEBR1RRmi3tV9aszCgw==
>X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
>Newsgroups: microsoft.public.dotnet.framework.aspnet
>Path: cpmsftngxa06.phx.gbl
>Xref: cpmsftngxa06.phx.gbl

microsoft.public.dotnet.framework.aspnet:189810
>NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>
>It seems all of the sudden that user controls that
>contain images are referencing image sources relative to
>the document that I drop the control on. This obviously
>does not work beacuase the image source is relative to
>the user control, not necessarily the form. Can anyone
>tell me why this would be the case?
>


Nov 17 '05 #7
I tested this on VS.NET 2002 and the 1.0 and 1.1 Framework and could not
reproduce it. I then tested the same thing on VS.NET 2003 and again could
not reproduce it.

I created a new user control and added an Image control to it. I then set
the image src and it is relative to the user control (which is what I would
expect since the dialog is set to Document Relative.) I then add my user
control to a webform in another folder (so that the relative path will be
different) and then build and browse. The image link is corrected to be
relative to the page.

Can someone encountering this problem provide me with some repro steps?

Jim Cheshire [MSFT]
Developer Support
ASP.NET
ja******@online.microsoft.com

This post is provided as-is with no warranties and confers no rights.

--------------------
From: "Brian W" <brianw@gold_death_2_spam_rush.com>
References: <00****************************@phx.gbl> <cd*************@cpmsftngxa06.phx.gbl>
<e7**************@TK2MSFTNGP12.phx.gbl>
<SI**************@cpmsftngxa06.phx.gbl>Subject: Re: Driving me nuts...
Date: Mon, 10 Nov 2003 15:41:24 -0800
Lines: 142
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <#8**************@TK2MSFTNGP11.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: dsl-107.goldrush.com 206.171.170.107
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP11.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:189892
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

For reference, see this thread started December of last year in this very NG
http://groups.google.com/groups?hl=e...elm=OXBB3MEsCH A.1656%40TK2MSFTNGP09

Brian W
"Jim Cheshire [MSFT]" <ja******@online.microsoft.com> wrote in message
news:SI****************@cpmsftngxa06.phx.gbl...
Brian,

Let me have a look into this. I'll post back to this thread ASAP.

Jim Cheshire [MSFT]
Developer Support
ASP.NET
ja******@online.microsoft.com

This post is provided as-is with no warranties and confers no rights.

--------------------
>From: "Brian W" <brianw@gold_death_2_spam_rush.com>
>References: <00****************************@phx.gbl>

<cd*************@cpmsftngxa06.phx.gbl>
>Subject: Re: Driving me nuts...
>Date: Mon, 10 Nov 2003 12:15:20 -0800
>Lines: 89
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
>Message-ID: <e7**************@TK2MSFTNGP12.phx.gbl>
>Newsgroups: microsoft.public.dotnet.framework.aspnet
>NNTP-Posting-Host: dsl-107.goldrush.com 206.171.170.107
>Path:

cpmsftngxa06.phx.gbl!TK2MSFTNGXA06.phx.gbl!TK2MSF TNGXA05.phx.gbl!TK2MSFTNGP

0
8.phx.gbl!TK2MSFTNGP12.phx.gbl
>Xref: cpmsftngxa06.phx.gblmicrosoft.public.dotnet.framework.aspnet:189838 >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>
>This is exactly the problem
>
>When placing an image control on a UserControl the path assigned to the
>image will be relative to the user control which is not necessarily the

same
>as the webform the user control is placed on.
>
>Take the following example:
>
>I have a folder/structure like this
>
>root \+
> Default.aspx
> +- images\
> mypicture.jpg
> +- controls
> myheader.ascx
> +- help\
> about.aspx
>
>if I place an image control on myheader.ascx and use the designer toassign >the image, the designer assigns ../images/mypicture.jpg to the ImageUrl
>attribute.
>
>When I place myheader.ascx on Default.aspx (which reside in the root) and >run the app the link to mypicture.jpg is broken because
>../images/mypicture.jpg is not the correct relative path in the contextof >Default.aspx.
>
>Now, if I place myheader.ascx on about.aspx (residing in help directory)

the
>link is un-broken because the relative path for about.aspc is correct.
>
>Clear as mud, right?!?! ;-)
>
>I actually brought this very topic up several months ago in this or theIDE >NG.
>
>
>Brian W
>
>
>
>
>"Jim Cheshire [MSFT]" <ja******@online.microsoft.com> wrote in message
>news:cd*************@cpmsftngxa06.phx.gbl...
>> Marty,
>>
>> I'm a bit confused. The URL to the image will have to be relative tothe >> Webform onto which your user control is placed. If not, the image link >> will be broken.
>>
>> Jim Cheshire [MSFT]
>> Developer Support
>> ASP.NET
>> ja******@online.microsoft.com
>>
>> This post is provided as-is with no warranties and confers no rights.
>>
>> --------------------
>> >Content-Class: urn:content-classes:message
>> >From: "Marty" <an*******@discussions.microsoft.com>
>> >Sender: "Marty" <an*******@discussions.microsoft.com>
>> >Subject: Driving me nuts...
>> >Date: Mon, 10 Nov 2003 11:07:37 -0800
>> >Lines: 6
>> >Message-ID: <00****************************@phx.gbl>
>> >MIME-Version: 1.0
>> >Content-Type: text/plain;
>> > charset="iso-8859-1"
>> >Content-Transfer-Encoding: 7bit
>> >X-Newsreader: Microsoft CDO for Windows 2000
>> >Thread-Index: AcOnvefxXWxzEBR1RRmi3tV9aszCgw==
>> >X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
>> >Newsgroups: microsoft.public.dotnet.framework.aspnet
>> >Path: cpmsftngxa06.phx.gbl
>> >Xref: cpmsftngxa06.phx.gbl
>microsoft.public.dotnet.framework.aspnet:189810
>> >NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
>> >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>> >
>> >It seems all of the sudden that user controls that
>> >contain images are referencing image sources relative to
>> >the document that I drop the control on. This obviously
>> >does not work beacuase the image source is relative to
>> >the user control, not necessarily the form. Can anyone
>> >tell me why this would be the case?
>> >
>>
>
>
>



Nov 17 '05 #8
Hello Jim,

I've created several user controls with no problem, but
only recently have I included images in them, resulting
in the problem I identified. My app structure is the
following:

<bin>
<images>
<forms>
legal.aspx
...
<usercontrols>
main.aspx

When I place a user control in a same level directory as
the <usercontrols> directory (such as a form in the
<forms> directory all is fine. But when I place a user
control in the main.aspx page, which is in the root, the
images in the user control are not resolved.

This is not really a big deal, but it would sure be nice
to be able to see the images used in the user control in
the designer. As it is now, I had to use the methods I
described in my last post, resulting in empty image
placeholders from the designer. Like I said, it's not a
big deal. Maybe I'm doing something wrong, but I've also
seen other posts from individuals who had to resort to
what I did to make this work. One would think, though,
that the image sources in a user control would correct
themselves when they are placed on a form.
Nov 17 '05 #9
Annoying, yes. You didn't reply to the same thread, so I can't see the
previous discussion, but the solution to this problem is to use absolute URL
paths for all your images. For example ...
imgsrc="http://yourdotcom.com/images/myimageisprettierthanyours.jpg"

NOW - I'd love to find a solution to the problem of having multiple projects
.... and having to create multiple copies of the user control so you have one
in each project. Wouldn't it be slick if you could share user controls
across projects without having to create a custom control in a .dll?

mark

"Marty" <an*******@discussions.microsoft.com> wrote in message
news:07****************************@phx.gbl...
Hello Jim,

I've created several user controls with no problem, but
only recently have I included images in them, resulting
in the problem I identified. My app structure is the
following:

<bin>
<images>
<forms>
legal.aspx
...
<usercontrols>
main.aspx

When I place a user control in a same level directory as
the <usercontrols> directory (such as a form in the
<forms> directory all is fine. But when I place a user
control in the main.aspx page, which is in the root, the
images in the user control are not resolved.

This is not really a big deal, but it would sure be nice
to be able to see the images used in the user control in
the designer. As it is now, I had to use the methods I
described in my last post, resulting in empty image
placeholders from the designer. Like I said, it's not a
big deal. Maybe I'm doing something wrong, but I've also
seen other posts from individuals who had to resort to
what I did to make this work. One would think, though,
that the image sources in a user control would correct
themselves when they are placed on a form.

Nov 17 '05 #10

"Mark" <fi**************@umn.edu> wrote in message
news:ei**************@TK2MSFTNGP09.phx.gbl...
Annoying, yes. You didn't reply to the same thread, so
Actually, Marty did reply to the same thread.

previous discussion, but the solution to this problem is to use absolute URL paths for all your images. For example ...
imgsrc="http://yourdotcom.com/images/myimageisprettierthanyours.jpg"
Which prevents you from developing on one machine and later copying to a
server (testing or production) with a different path.

In many situations, copying anything to production before it is "released"
is forbidden by policy.

And the solution is as follows:

Use <asp:Image> control and use a relative path (relative to the user
control). For example if your user controls are in a subdirectory called
"Controls" and your images are in "Images" you would do something like the
following:

<asp:image id="img1" runat="server"
imageurl="../images/myimage.jpg"></asp:image>

No matter where the user control is in relation to the document it is placed
on the image will not be broken.

This works with <asp:hyperlink> control too.

This does not work if you use <img> or <a> tags, on your user controls.

If you are using the Property browser use the images selector, make sure
t6he URL Type is set to "Document Relative"
HTH

Regards
Brian W


NOW - I'd love to find a solution to the problem of having multiple projects ... and having to create multiple copies of the user control so you have one in each project. Wouldn't it be slick if you could share user controls
across projects without having to create a custom control in a .dll?

mark

"Marty" <an*******@discussions.microsoft.com> wrote in message
news:07****************************@phx.gbl...
Hello Jim,

I've created several user controls with no problem, but
only recently have I included images in them, resulting
in the problem I identified. My app structure is the
following:

<bin>
<images>
<forms>
legal.aspx
...
<usercontrols>
main.aspx

When I place a user control in a same level directory as
the <usercontrols> directory (such as a form in the
<forms> directory all is fine. But when I place a user
control in the main.aspx page, which is in the root, the
images in the user control are not resolved.

This is not really a big deal, but it would sure be nice
to be able to see the images used in the user control in
the designer. As it is now, I had to use the methods I
described in my last post, resulting in empty image
placeholders from the designer. Like I said, it's not a
big deal. Maybe I'm doing something wrong, but I've also
seen other posts from individuals who had to resort to
what I did to make this work. One would think, though,
that the image sources in a user control would correct
themselves when they are placed on a form.


Nov 17 '05 #11
Jim,

Thanks for your time.

I can no longer confirm this on VS.NET 2002. (I don't have it installed any
longer)

I know this behavior is present in VS.NET 2003 present if you are using an
HTML <img> tag, but, that's kind of expected.

I would be interested in performance differences between the 2 following
lines of code:

<img src='<%=ResolveUrl("~/images/mypicture.jpg")%>'

<asp:image id="img1" runat="server"
imageurl="~/images/mypicture.jpg"></asp:image>
Regards
Brian W

"Jim Cheshire [MSFT]" <ja******@online.microsoft.com> wrote in message
news:j0**************@cpmsftngxa06.phx.gbl...
I tested this on VS.NET 2002 and the 1.0 and 1.1 Framework and could not
reproduce it. I then tested the same thing on VS.NET 2003 and again could
not reproduce it.

I created a new user control and added an Image control to it. I then set
the image src and it is relative to the user control (which is what I would expect since the dialog is set to Document Relative.) I then add my user
control to a webform in another folder (so that the relative path will be
different) and then build and browse. The image link is corrected to be
relative to the page.

Can someone encountering this problem provide me with some repro steps?

Jim Cheshire [MSFT]
Developer Support
ASP.NET
ja******@online.microsoft.com

This post is provided as-is with no warranties and confers no rights.

--------------------
From: "Brian W" <brianw@gold_death_2_spam_rush.com>
References: <00****************************@phx.gbl>

<cd*************@cpmsftngxa06.phx.gbl>
<e7**************@TK2MSFTNGP12.phx.gbl>
<SI**************@cpmsftngxa06.phx.gbl>
Subject: Re: Driving me nuts...
Date: Mon, 10 Nov 2003 15:41:24 -0800
Lines: 142
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <#8**************@TK2MSFTNGP11.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: dsl-107.goldrush.com 206.171.170.107
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP11.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:189892
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

For reference, see this thread started December of last year in this very

NG


http://groups.google.com/groups?hl=e...elm=OXBB3MEsCH
A.1656%40TK2MSFTNGP09


Brian W
"Jim Cheshire [MSFT]" <ja******@online.microsoft.com> wrote in message
news:SI****************@cpmsftngxa06.phx.gbl...
Brian,

Let me have a look into this. I'll post back to this thread ASAP.

Jim Cheshire [MSFT]
Developer Support
ASP.NET
ja******@online.microsoft.com

This post is provided as-is with no warranties and confers no rights.

--------------------
>From: "Brian W" <brianw@gold_death_2_spam_rush.com>
>References: <00****************************@phx.gbl>
<cd*************@cpmsftngxa06.phx.gbl>
>Subject: Re: Driving me nuts...
>Date: Mon, 10 Nov 2003 12:15:20 -0800
>Lines: 89
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
>Message-ID: <e7**************@TK2MSFTNGP12.phx.gbl>
>Newsgroups: microsoft.public.dotnet.framework.aspnet
>NNTP-Posting-Host: dsl-107.goldrush.com 206.171.170.107
>Path:

cpmsftngxa06.phx.gbl!TK2MSFTNGXA06.phx.gbl!TK2MSF TNGXA05.phx.gbl!TK2MSFTNGP
0 8.phx.gbl!TK2MSFTNGP12.phx.gbl
>Xref: cpmsftngxa06.phx.gbl

microsoft.public.dotnet.framework.aspnet:189838
>X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>
>This is exactly the problem
>
>When placing an image control on a UserControl the path assigned to the >image will be relative to the user control which is not necessarily the same
>as the webform the user control is placed on.
>
>Take the following example:
>
>I have a folder/structure like this
>
>root \+
> Default.aspx
> +- images\
> mypicture.jpg
> +- controls
> myheader.ascx
> +- help\
> about.aspx
>
>if I place an image control on myheader.ascx and use the designer to

assign
>the image, the designer assigns ../images/mypicture.jpg to the ImageUrl >attribute.
>
>When I place myheader.ascx on Default.aspx (which reside in the root) and >run the app the link to mypicture.jpg is broken because
>../images/mypicture.jpg is not the correct relative path in the contextof
>Default.aspx.
>
>Now, if I place myheader.ascx on about.aspx (residing in help
directory) the
>link is un-broken because the relative path for about.aspc is correct.
>
>Clear as mud, right?!?! ;-)
>
>I actually brought this very topic up several months ago in this or the
IDE
>NG.
>
>
>Brian W
>
>
>
>
>"Jim Cheshire [MSFT]" <ja******@online.microsoft.com> wrote in message
>news:cd*************@cpmsftngxa06.phx.gbl...
>> Marty,
>>
>> I'm a bit confused. The URL to the image will have to be relative
tothe
>> Webform onto which your user control is placed. If not, the image

link >> will be broken.
>>
>> Jim Cheshire [MSFT]
>> Developer Support
>> ASP.NET
>> ja******@online.microsoft.com
>>
>> This post is provided as-is with no warranties and confers no

rights. >>
>> --------------------
>> >Content-Class: urn:content-classes:message
>> >From: "Marty" <an*******@discussions.microsoft.com>
>> >Sender: "Marty" <an*******@discussions.microsoft.com>
>> >Subject: Driving me nuts...
>> >Date: Mon, 10 Nov 2003 11:07:37 -0800
>> >Lines: 6
>> >Message-ID: <00****************************@phx.gbl>
>> >MIME-Version: 1.0
>> >Content-Type: text/plain;
>> > charset="iso-8859-1"
>> >Content-Transfer-Encoding: 7bit
>> >X-Newsreader: Microsoft CDO for Windows 2000
>> >Thread-Index: AcOnvefxXWxzEBR1RRmi3tV9aszCgw==
>> >X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
>> >Newsgroups: microsoft.public.dotnet.framework.aspnet
>> >Path: cpmsftngxa06.phx.gbl
>> >Xref: cpmsftngxa06.phx.gbl
>microsoft.public.dotnet.framework.aspnet:189810
>> >NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
>> >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
>> >
>> >It seems all of the sudden that user controls that
>> >contain images are referencing image sources relative to
>> >the document that I drop the control on. This obviously
>> >does not work beacuase the image source is relative to
>> >the user control, not necessarily the form. Can anyone
>> >tell me why this would be the case?
>> >
>>
>
>
>


Nov 17 '05 #12
I hear you Mark.

All I can say is that I have confidense in Microsoft, in
that some of these issues might be resolved in a future
release of dotnet. What troubles me, and this might be
better suited for a different thread, is that we have to
firstly experience all of these quirks (however much time
this takes), and then find a 'work-around' for each. I
guess this is inherent with any application. For
instance, when will the day come when we can load VS.Net,
and maybe ComponentOne components, and call it a day?
We're almost there with VS, but I still use Dreamweaver,
Photoshop, and good 'ol TextPad to drill down to levels
that VS isn't so good with. Like I said...I have
confidense in Microsoft.
Nov 17 '05 #13

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

Similar topics

6
by: Keiron Waites | last post by:
Please see the problem in action here: http://www.leadbullet.biz/contact.php If you mouse over the fields, you will see that text is shown on the right. The text makes the other fields move when...
0
by: Simon Harris | last post by:
Ok, this really is driving me nuts!!! :( 'All' I am trying to do is get the value of a named element. My XML doc is: <?xml version="1.0" encoding="utf-16" standalone="yes" ?> - <Page>...
2
by: ipmccun | last post by:
Hello all: Perhaps someone can shed some light on this: I'm trying to create a situation, while debugging, where a long running request (sleeps for 15s) and a short running request execute...
4
by: trond | last post by:
Hello all, Before I start I'd like to point out that I am a complete novice when it comes to asp.net - My background is in network and operating systems, and although I have been doing a bit of...
2
by: mitsura | last post by:
Hi, I need to read a simle XML file. For this I use the SAX parser. So far so good. The XML file consist out of number of "Service" object with each object a set of attributes. I read...
5
by: jason.neo | last post by:
Hi all experts, I am going nuts with this Invalid postback or callback argument thingy with .Net 2.0 I am building a file attachment module which relays on a Datatable stored in session (yeah...
4
by: mattlightbourn | last post by:
Hi all, I have a problem which has been driving me nuts. Crosstab queries! I have a database witch a few different tables to do with garment manufacturing. I have a table for a client...
3
by: DuncanIdaho | last post by:
Hello experts IE 7.0.5730.11 Opera 9.27 Firefox 2.0.0.14 This problem only occurs in Opera and Firefox (amazing, IE does something right, or maybe not) Anyway, the problem is that when I...
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?
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.