母版页中的相对路径问题 [英] Relative path problem in master page

查看:105
本文介绍了母版页中的相对路径问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个母版页(Project>> MasterPages>>> MainPage.master),并且该页中的某些图像带有一些路径,例如"../../Images/bg_main_menu.png".

我以两种形式引用此母版页.这些路径中的一种形式在路径中:项目>> Forms>> Form1.aspx,另一种形式是:Project>> Forms>> NewFolder>> Form2.aspx

现在对于Form2.aspx,图像不会被加载.

我使用〜Images/bg_main_menu.png"尝试了图像路径.但这不起作用.

有人可以帮忙吗?

问候,
Snigdha

Hi All,

I have got a master page(Project>>MasterPages>>MainPage.master) and some images in that page with some path like "../../Images/bg_main_menu.png".

I refer this master page in two forms. One of those form is oresent in the path : Project>>Forms>>Form1.aspx and the other one is : Project>>Forms>>NewFolder>>Form2.aspx

Now for Form2.aspx the image is not getting loaded.

I tried the image path with "~Images/bg_main_menu.png". But it is not working.

Can somebody help?

Regards,
Snigdha

推荐答案

有些类似于ResolveUrl.它应该可以帮助您.
此处阅读 [此处 [http://www.codeproject.com/Tips/62855/Resolving-Paths-in-a-Multi-Folder-WebSite.aspx>此处 [ ^ ].您应该使用它.


There is something like ResolveUrl. It should help you out.
Read about it here[^].

A good Tip related to it is posted here[^]. You should use it.


sargamlucy写道:
sargamlucy wrote:

〜Images/bg_main_menu.png".

"~Images/bg_main_menu.png".


在TILDA(〜)之后,在Images之前,您缺少正斜杠.
〜/Images/....


You are missing a forward slash after TILDA (~), before Images.
~/Images/....


有关同一问题的msdn上有一些信息:

http://msdn.microsoft.com/en-us/library/ms178116.aspx [ ^ ]


也许通过添加额外的/
一样简单


〜/Images/bg_main_menu.png"

祝你好运!
There is some info on msdn about the same issue:

http://msdn.microsoft.com/en-us/library/ms178116.aspx[^]


Maybe it''s just as simple by adding the extra /



"~/Images/bg_main_menu.png"

Good luck!


ResolveUrl dint可以正常工作,但是通过搜索,我又得到了一个叫做ResolveClientUrl的东西.

这两者之间的区别是... ResolveUrl可用于ASP控件,而ResolveClientUrl可用于html控件.


但是现在我还有一个问题.此技术无法在样式表中解决.如果我要在样式类中提及任何背景图片,那么这是行不通的.

我该怎么办?
ResolveUrl dint work properly, but searching for that, i got one more thing called ResolveClientUrl.

The difference between these two is... ResolveUrl can be used for ASP controls and ResolveClientUrl can be used for html controls.


But now I have one more problem. This technique is not working out inside style sheet. If i am mentioning any background image to a style class, then this is not working.

What should I do?


这篇关于母版页中的相对路径问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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