relative url in asp.net website applications

后端 未结 3 1822
你的背包
你的背包 2020-12-22 08:18

I have an image that I want to use it\'s src attribute in relative format

when my website URL was http://localhost/ I used to use this code to access th

相关标签:
3条回答
  • 2020-12-22 08:33

    @rrrr is right, that the way to do it,

    <asp:Image runat="server" ID="myImage" ImageUrl="~/Files/pic.png" /> 
    

    but I would use a standard html image with runat="server"

    <img runat="server" src="~/YourPath/image.png">
    

    Reason : less server side controls

    0 讨论(0)
  • 2020-12-22 08:35

    You can use ~ symbol to represent root in ASP.Net

    <asp:Image ID="Image1" runat="server"  ImageUrl="~/Files/pic.png"/>
    
    0 讨论(0)
  • 2020-12-22 08:47

    Use tilde ~ in a server control to use a relative path.

    <asp:Image runat="server" ID="myImage" ImageUrl="~/Files/pic.png" />
    
    0 讨论(0)
提交回复
热议问题