Tuesday, June 16, 2009

Point to root directory Image Display Problem and Solution in Asp.net

Master Page is creating problem when a page inside folder is trying to refer master page. The reason of problem is Master Page is using absolute image url, which changes when you try to refer same inside folder.

A simple solution to problem is to define relative path for images inside master page.

So if you have coded like following in your MasterPage File

<img src="Images/Logo.gif"/>

Than Replace it with, 


<img src="<%= Page.ResolveUrl("~")%>Images/Logo.gif"/>

No comments: