Solved

Unable to Display Image in ASP.NET Using C#

Posted on 2011-09-20
4
396 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

734 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