문제

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.

도움이 되었습니까?

해결책

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

다른 팁

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" />
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top