Solved

Unable to Display Image in ASP.NET Using C#

Posted on 2011-09-20
4
390 Views
Last Modified: 2012-05-12
I am attempting to display an image on my header of a ASP.NET web page I am creating, and I am only getting a box with an "x" in it representing the location where the picture is supposed to appear. I have checked to make sure that the picture is in the same directory as the main project files, and they are present. I have also made sure that the Default.ASPX page does contain a valid reference to the location of the image attempting to be used, and I receive the attached results. Could someone help me figure out what I am doing wrong with regards to syntax in ASP.NET? Any and all help would be greatly appreciated.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="FuelReceiptsResearch._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Fuel Receipt Research</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table>
            <tr>
                <td colspan="2"><img src="ta_header.jpg" alt = 
                        style="width: 133px; margin-bottom: 18px"  /></td>
            </tr>        
        </table>
        <asp:Image ID="Image1" src = "ta_header.jpg" runat="server" Width="110px" />
    
    </div>
    </form>
</body>
</html>

Open in new window

Results of Web Page Source Code Directory With Image
0
Comment
Question by:thenthorn1010
  • 3
4 Comments
 
LVL 22

Expert Comment

by:plusone3055
ID: 36567831
stop your Service and restart it :)

its always common practice in ASP App to make a Images Folder
and drag the image from the folder onto your code creating a perfect link :)
0
 

Author Comment

by:thenthorn1010
ID: 36568051
plusone3055,

Thank you for the advice...I did start and stop the service that was running, and I am still ending up with a box with a red "X" in it on the upper hand corner of the screen. (In my run-time environment, I see the image that should be displayed without any issue, after taking your suggestion of dragging the image from the source folder to get a "perfect link.")

Is there anything else that I am missing that is causing this issue when I run the ASP site in debug mode?

Thanks
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="FuelReceiptsResearch._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Fuel Receipt Research</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table>
                <tr>
                <td colspan="2"><img alt="" src="../ta_header.jpg" /></td></tr>
        </table>
    
    </div>
    </form>

</body>
</html>

Open in new window

Updated Web Site Results Run Time View of VS 2008 Environment
0
 

Accepted Solution

by:
thenthorn1010 earned 0 total points
ID: 36588805
The issue was resolved by adding the items indvidually to the Visual Studio project and recreating all directories within VS 2008 Team and moving all of the images being used into the corresponding directory. it seemed as though Windows XP and VS 2008 would not recognize the directory where the image was located and it took several attempts of removing the image from the project and just adding the image again in order to have this issue resolved. This issue seems like a bug within MS Visual Studio 2008 and Windows XP.
0
 

Author Closing Comment

by:thenthorn1010
ID: 36715384
Resolved issue on my own by just playing with Visual Studio 2008 and Windows XP until the development studio recognized the directory that I was using and the image that was being used. None of the code changed from the code that was originally posted to this question in making the image appear. It just seems as though there was an issue inside of VS 2008 and Windows XP not picking up a directory with the specified image that was to be used.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now