Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relative Path in master page for img tag

I have a tag in a master page. I use this master page in many folders. So the src path of the tag should be different for each folder. Here is my code :

<img src="images/1.gif" />

and I have a folder named "images" and a folder named "Users". Master Page is in the root, but I use it in Users folder.

How can I set a dynamic address for src?

like image 676
Mehdi Dehghani Avatar asked Oct 01 '09 20:10

Mehdi Dehghani


1 Answers

The easiest way would be to use an asp:Image tag. You need to add runat="server" in order to use ~ syntax to resolve your URLs.

<asp:Image ID="myImage" runat="server" ImageUrl="~/images/1.gif" />
like image 107
Matt Hidinger Avatar answered Oct 06 '22 12:10

Matt Hidinger