使我抓狂... [英] Driving me nuts...

查看:87
本文介绍了使我抓狂...的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎突然用户控制

包含图像引用的图像源相对于我放弃控件的文件。这显然

不起作用beacuase图像源是相对于用户控制的
,不一定是表格。任何人都可以告诉我为什么会这样吗?

解决方案

FWIW,这也让我疯狂! />

这是我为asp图像做的,在页面上删除控件之后

(或用户控件)我将ImageUrl改为像

"〜/''images / mypicture.jpg"


对于IMG html控件,我使用src ="<%= ResolveUrl("〜/ / image / mypicture.jpg")%>"


这两个方面的缺点是你无法在
$ b $中看到实际的图像b设计模式,只有地点标记。


HTH

Brian W


" Marty" <一个******* @ discussions.microsoft.com>在留言中写道

news:00 **************************** @ phx.gbl ... < blockquote class =post_quotes>似乎突然之间,用户控制
包含图像是相对于我放弃控件的文档引用图像源。这显然
不起作用的图像源是相对于用户控制的,不一定是表格。任何人都可以告诉我为什么会这样吗?



Marty,


我'有点困惑。图像的URL必须相对于放置用户控件的

Webform。否则,图片链接

将被破坏。


Jim Cheshire [MSFT]

开发人员支持

ASP.NET
ja******@online.microsoft.com


这篇文章按原样提供,不作任何保证,也不授予任何权利。


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

Content-Class:urn:content-classes:message
From:" Marty" < an ******* @ discuss.microsoft.com>
发件人:Marty < an ******* @ discuss.microsoft.com>
主题:让我疯了......
日期:星期一,2003年11月10日11:07:37 -0800 行:6
消息ID:< 00 **************************** @ phx.gbl>
MIME-Version:1.0
Content-Type:text / plain;
charset =" iso-8859-1"
Content-Transfer-Encoding:7bit
X-新闻阅读器:用于Windows 2000的Microsoft CDO
线程索引:AcOnvefxXWxzEBR1RRmi3tV9aszCgw ==
X-MimeOLE:由Microsoft MimeOLE制作V5.50.4910.0300
新闻组:microsoft.public.dotnet.framework.aspnet
路径:cpmsftngxa06.phx.gbl
外部参照: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


用户控制
包含图像的突然之处似乎是引用相对于
的图像源我放弃控件的文档。这显然
不起作用的图像源是相对于用户控制的,不一定是表格。任何人都可以告诉我为什么会这样吗?




这正是问题

在UserControl上放置图像控件时,分配给

图像的路径将相对于用户控件,该控件不一定相同

作为用户控件放置在webform上。


采用以下示例:


我有一个像这样的文件夹/结构


root \ +

Default.aspx

+ - images \

mypicture.jpg

+ - 控制

myheader.ascx

+ - help \

about.aspx


如果我在myheader.ascx上放置一个图像控件并使用设计师为图像分配

,设计师将../images/mypicture.jpg分配给ImageUrl

属性。


当我将myheader.ascx放在Default.aspx(驻留在root中)和

运行应用程序链接到我的picture.jpg被打破是因为

... / images / mypicture.jpg在

Default.aspx的背景下不是正确的相对路径。


现在,如果我将myheader.ascx放在about.aspx上(驻留在帮助目录中),

链接是未破坏的,因为about.aspc的相对路径是正确的。


清除泥土吧?!?! ;-)


我几个月前在这个或IDE中实际上提到了这个话题

NG。

Brian W



" Jim Cheshire [MSFT]" < JA ****** @ online.microsoft.com>在消息中写道

news:cd ************* @ cpmsftngxa06.phx.gbl ...

Marty,

我有点困惑。图像的URL必须与用户控件所在的Webform相对。如果没有,图像链接将被破坏。

Jim Cheshire [MSFT]
开发人员支持
ASP.NET
ja ****** @ online.microsoft.com

这篇文章按原样提供,没有保证并且不赋予任何权利。

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

Content-Class:urn:content-课程:消息
来自:" Marty" < an ******* @ discuss.microsoft.com>
发件人:Marty < an ******* @ discuss.microsoft.com>
主题:让我疯了......
日期:星期一,2003年11月10日11:07:37 -0800 行:6
消息ID:< 00 **************************** @ phx.gbl>
MIME-Version:1.0
Content-Type:text / plain;
charset =" iso-8859-1"
Content-Transfer-Encoding:7bit
X-新闻阅读器:用于Windows 2000的Microsoft CDO
线程索引:AcOnvefxXWxzEBR1RRmi3tV9aszCgw ==
X-MimeOLE:由Microsoft MimeOLE制作V5.50.4910.0300
新闻组:microsoft.public.dotnet.framework.aspnet
路径:cpmsftngxa06.phx.gbl
外部参照: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?

解决方案

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?



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?




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?



这篇关于使我抓狂...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆