2012-07-06 113 views
0

下面的代碼不會顯示圖像,它確實顯示圖像存在但圖像不顯示。有任何想法嗎?ASP - 爲什麼這個img不顯示

<%@ Page Language="C#" MasterPageFile="~/Main_MP.master" AutoEventWireup="true" CodeFile="Phone.aspx.cs" 
    Inherits="Phone1" Title="Talk & Txt" %> 
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> 

<img src="Talk & Txt Page.jpg" alt="Smiley face" height="42" width="42" /> 

    <br /> 
<asp:Label ID="lblCounter" runat="server" Visible="False" Font-Bold="True" Font-Names="Calibri" Font-Size="Small" ForeColor="#C00000"></asp:Label></div> 
    </div> 
</asp:Content> 
+5

XHTML不能生'&'字符在裏面。 '&'和空格不是URI的安全字符。 – Quentin 2012-07-06 15:28:36

+0

我懷疑你的替代文字留下了一些需要的東西,建議閱讀http://www.alanflavell.org.uk/alt/alt-text.html。 – Quentin 2012-07-06 15:29:15

+0

預計會進行一些基本的調試。 Firebug/Chrome調試工具/等報告所請求的URL是什麼?服務器返回什麼HTTP響應代碼? – Quentin 2012-07-06 15:30:12

回答

0

用%20替換圖像URL(即'src')屬性中的空格。

URL中不能有空格,但%20應該可以工作。

+3

我懷疑這是個問題。瀏覽器非常擅長從特定錯誤中恢復。 – Quentin 2012-07-06 15:30:54

0

這是否圖像在同一目錄中的頁面,否則你需要給完整的相對路徑

2

的轉義&符號可能會導致您的問題。

+0

他們應該如何逃脫? – Quentin 2012-07-06 15:31:01

+0

+1。進一步說,重命名圖像將是一個好主意。使用這些字符的Aviod:http://dslrphotoforum.com/index.php?topic=211.0 – David 2012-07-06 15:31:58

+0

&是十進制實體 – RhinoWalrus 2012-07-06 15:33:41

1

將圖像文件重命名爲TalkAndTxtPage.jpg - 通過URL鏈接的所有文件(包括圖像)最好以不使用保留字符或不安全字符(空格(「」)和符號(「&」))命名。參考 - http://www.blooberry.com/indexdot/html/topics/urlencoding.htm

那麼做到這一點(也有一個壞<div>標籤):

<%@ Page Language="C#" MasterPageFile="~/Main_MP.master" AutoEventWireup="true" CodeFile="Phone.aspx.cs" 
    Inherits="Phone1" Title="Talk & Txt" %> 
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> 

<img src="TalkAndTxtPage.jpg" alt="Smiley face" height="42" width="42" /> 

    <br /> 
<asp:Label ID="lblCounter" runat="server" Visible="False" Font-Bold="True" Font-Names="Calibri" Font-Size="Small" ForeColor="#C00000"></asp:Label> 
    <div> 
    </div> 
</asp:Content> 
+0

好答案,所以+1。如果你包括***,爲什麼*** Ross應該重新命名圖像可能會更好。 ;-) – David 2012-07-06 15:36:10

0

從圖像名稱刪除空格。

<img src="Talk-Txt-Page.jpg" alt="Smiley face" height="42" width="42" /> 

此外,圖像位於相對於頁面的位置?您可能需要指向目錄。

<img src="/images/Talk-Txt-Page.jpg" alt="Smiley face" height="42" width="42" /> 

希望這有助於!

+0

圖像名稱中的空格不應該引起問題 - 我只是測試 – 2012-07-06 15:35:05

0

這是一個名爲Talk的圖像& Txt Page.jpg適用於我。

我看到一對夫婦在你的代碼結束的div標籤沒有一個開端DIV