Frage

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.

War es hilfreich?

Lösung

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"/>

Andere Tipps

The most foolproof method is to have something like this

<asp:Image runat="server" id="myImage" ImageUrl='<%# Eval("imageFile") %>' />

Then in the code-behind assign the variable imageFile to something like Server.MapPath("App_Themes/Home/images/logo.png");

Try the following:

<img src="~/App_Themes/Home/images/logo.png" runat="server" />
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top