相对路径不使用按钮内的img标签 [英] Relative path not working with img tag inside the button

查看:67
本文介绍了相对路径不使用按钮内的img标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我有html按钮标签,其中嵌套了我的应用程序中显示的图片标签。



问题是当我使用相对路径时,图像标签根本不起作用,但如果我使用绝对路径它就可以正常工作。



但是我不想使用绝对路径,因为如果我将它放在测试服务器和主服务器上,我需要更改它。



这是具有绝对路径的代码:

Hi All,

I have html button tag in which I have nested the image tag to show in my application.

The problem is when I use relative path the image tag does not work at all but if I use absolute path it works just fine.

But I do not want to use absolute path because I need to change it if I put this on test server and on main server.

Here is code with absolute path:

treeNode.Append(@"<button ><img src=""http://localhost:62473/mainFolder/Images/image1.png"" width=""30"" height=""15"" alt=""Get Info""></button>");





这是具有相对路径的代码:







Here is code with relative path:


treeNode.Append(@"<button ><img src=""~/Images/image1.png"" width=""30"" height=""15"" alt=""Get Info""></button>");







请帮帮我,告诉我哪里出错了?




Please help me and let me know where I am going wrong?

推荐答案

当然它总是有效的。你没有试过在任何地方使用相对路径,所以我不知道你把它搞砸了。该路径应该使用路径相对于HTML文件。也许您不太了解路径语法:'。'是这个目录,'..'表示一级,'〜'表示为您的站点设置的根目录,依此类推。



-SA
Of course it always works. You did no try use relative path anywhere, so I don't know where you screwed it up. The path should be relative the the HTML file using the path. Perhaps you don't quite know the path syntax: '.' is "this directory", '..' means one level up, '~' means root directory set up for your site, and so on.

—SA


这篇关于相对路径不使用按钮内的img标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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