Search code examples
asp.netvisual-studio-2008master-pagescontent-pagesresolveurl

How to give path for image in a master page for two sub-pages in two locations?


Hi all my work environment is asp.net c# vs2008. My issue is this, i have a master page outside.master in shared folder.Inside it i have an image control with

<img src="App_Themes/Home/images/logo.png" />

i am referring this master page from in two sub pages. One is Index.aspx which is located in the root level and Secondly registration.aspx which is under masters folder. The problem is that when i run, the index.aspx will show the logo where registration.aspx is not showing the logo. Please tell me how to specify the path so that i will get logo in both pages.


Solution

  • Tilde sign ~ will resolve for server side controls.

    So you need to add runat="server" as img in HTML element.

    Try this:

    <img src="~/App_Themes/Home/images/logo.png" runat="server"/>