Click here to Skip to main content
15,902,939 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Why the photo is not displaying in web page.My HTML and CS coading is given below.Only image icon is displaying in place of image.


HTML Part
<body>
    <form id="form1"  runat="server">
    <div>
    
        <asp:Image ID="Image1" runat="server" ImageUrl="~/blank.jpg" />
        <br />
        <br />
        <br />
        <br /> 
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <br />
        <br />
        <br />
        <br />
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        <br />
        <br />
        <br />
        <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
        <br />
        <br />
    <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>
    </div>
    </form>
</body>
</html>



CS Part is given below


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Data;
using System.IO;


public partial class Retrive_Data_From_Database_and_display_in_TextBox : System.Web.UI.Page
{
    OleDbConnection con;
    OleDbCommand com;
    OleDbDataAdapter da;
    DataSet ds;
    protected void Page_Load(object sender, EventArgs e)
    {
        con = new System.Data.OleDb.OleDbConnection();
        ds = new DataSet();
        con.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("~/kamnagroup.mdb") + "";
        string sql = "select aname,add1,photo,point from joining WHERE point=(SELECT MAX(point) FROM joining)";
        da = new System.Data.OleDb.OleDbDataAdapter(sql,con);
        con.Open();
        da.Fill(ds,"joining");
        navigatedata();
        con.Close();
        
    }
    private void navigatedata()
    {
        DataRow dRow=ds.Tables["joining"].Rows[0];
        System.Web.UI.WebControls.Label lbl1 = new System.Web.UI.WebControls.Label();
        TextBox1.Text = dRow.ItemArray.GetValue(0).ToString();
        TextBox2.Text = dRow.ItemArray.GetValue(1).ToString();
        lbl1.Text = dRow.ItemArray.GetValue(2).ToString();
        TextBox3.Text = dRow.ItemArray.GetValue(3).ToString();
        TextBox4.Text = dRow.ItemArray.GetValue(2).ToString();
        Image1.ImageUrl = System.IO.Path.GetFileName(lbl1.Text);

    }
}
Posted
Updated 26-Jan-12 20:18pm
v2

1 solution

Form that we can't necessarily tell.
However, I would open the page in the browser, and either right click on it to "View Source", (IE) or Right click the image and "Insepect element" (Chrome) - FF will have similar.
You can then look at what the HTML is trying to display for the image in terms of the url. I suspect that it will be a Server based HDD address, which is of no use what so ever to a Client based browser...


Have a look at this: A generic Image-From-DB class for ASP.NET[^] - it may not cover your needs exactly since it assumes the image is actually stored in the DB, but it should be easy for you to modify to fit your circumstances.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900