Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Unable to Display Image in ASP.NET Using C#

Posted on 2011-09-20
4
Medium Priority
?
401 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

721 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