日期:2014-05-18  浏览次数:20374 次

用户控件里的图片为什么显示不出来?
同样的代码主页default.aspx就能显示出来图片,可是News目录的NewsDetails就显示不出来,也跳转不到主页,请问什么问题?折腾了一天了

<%@   Control   Language= "c# "   AutoEventWireup= "false "   Codebehind= "SiteHeader.ascx.cs "   Inherits= "Test.Controls.SiteHeader "   TargetSchema= "http://schemas.microsoft.com/intellisense/ie5 "   %>
<table   class= "Site_Header "   width= "100% ">
<tr>
<td   width= "50% "> <asp:hyperlink   id= "lnkLogo "   Runat= "server "   ImageUrl= "../images/logo.bmp "   NavigateUrl= "../default.aspx "> </asp:hyperlink> </td>
<td   vAlign= "bottom "   align= "right "> <asp:label   id= "lblGreeting "   runat= "server "> </asp:label> &nbsp;&nbsp;
<asp:hyperlink   id= "lnkUser "   Visible= "true "   Runat= "server "> </asp:hyperlink> &nbsp;&nbsp;
<asp:linkbutton   id= "lbtnSignOut "   runat= "server "   Visible= "False "   CausesValidation= "False "> 注销 </asp:linkbutton> </td>
</tr>
</table>


------解决方案--------------------
asp:hyperlink id= "lnkLogo " Runat= "server " ImageUrl= "../images/logo.bmp " NavigateUrl= "../default.aspx "> </asp:hyperlink>
=======================
asp:hyperlink id= "lnkLogo " Runat= "server " ImageUrl= "~/images/logo.bmp " NavigateUrl= "~/default.aspx "> </asp:hyperlink>

你的目录结构结构应该是
根目录
--News
--Controls

用户控件是在当前页面编译的,所以如果你还沿用以前的相对路径编译器会在当前目录下去找 images/logo.bmp,所以肯定是找不到地