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
@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
You can use ~ symbol to represent root in ASP.Net
<asp:Image ID="Image1" runat="server" ImageUrl="~/Files/pic.png"/>
Use tilde ~
in a server control to use a relative path.
<asp:Image runat="server" ID="myImage" ImageUrl="~/Files/pic.png" />