Ross
Ross

Reputation: 127

ASP - Why does this img not display

The following code will not display the image, it does show that an image is present but the image does not display. Any ideas?

 <%@ 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>

Upvotes: 0

Views: 172

Answers (6)

EkoostikMartin
EkoostikMartin

Reputation: 6911

Rename the image file to TalkAndTxtPage.jpg - All files linked via URL, including images, are best named without using reserved or unsafe characters (both space (" ") and ampersand ("&") fit into this category). Reference - http://www.blooberry.com/indexdot/html/topics/urlencoding.htm

Then do this (you also had a bad <div> tag):

 <%@ 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>

Upvotes: 1

G-Man
G-Man

Reputation: 7241

this alone with an image named Talk & Txt Page.jpg works on my side.

I see a couple of ending div tags in your code that do not have a beginning div

Upvotes: 0

Ravi Ram
Ravi Ram

Reputation: 24488

Remove the spaces from the image name.

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

Also, where is the image located in relation to the page? You might need to point to the directory.

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

Hope this helps!

Upvotes: 0

RhinoWalrus
RhinoWalrus

Reputation: 3089

The unescaped ampersands may be causing your issue.

Upvotes: 2

Amal Dev
Amal Dev

Reputation: 1978

Does that image is in the same directory as the page, otherwise you need to give the full relative path

Upvotes: 0

Peter Bernier
Peter Bernier

Reputation: 8078

Replace the spaces in the image URL (ie, the 'src') attribute with %20.

You can't have spaces in a URL, but %20 should work.

Upvotes: 0

Related Questions