Surendra Sharma

Surendra Sharma

Search This Blog

Sunday, March 29, 2015

How to specify location of images in aspx page for Sitecore

I was clueless while displaying search image in all the aspx pages and ascx web control of Sitecore. As on some pages I was getting my image but while on some pages I was not missing the image.

I tried different path as below but all was wrong

<img src="../images/search.png" alt="search image" />
<img src="~/images/search.png" alt="search image" />
<img src="images/search.png" alt="search image" />

Correct one is to use path that starts with “/” as it automatically resolve its path as below

<img src="/images/search.png" alt="search image" />

Final note is - Never specify "../" for any image as for any web request IIS resolve it accordingly. So always write root path as "/" + physical image path.

Hope it helps someone in anyway.


Please leave your comments or share this tip if it’s useful for you.

No comments:

Post a Comment