为什么照片未显示在网页中. [英] Why the photo is not displaying in web page.

查看:77
本文介绍了为什么照片未显示在网页中.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么照片不显示在网页上.我的HTML和CS编码如下所示.仅图像图标代替图像显示.


HTML零件

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);

    }
}

推荐答案

我们不一定能说出的表格.
但是,我将在浏览器中打开该页面,然后右键单击该页面以查看源代码"(IE),或者右键单击该图像,然后单击检查元素"(Chrome)-FF将具有类似的功能.
然后,您可以根据URL查看HTML试图显示的图像.我怀疑这将是基于服务器的HDD地址,对于基于客户端的浏览器来说这毫无用处...


看看以下内容:通用Image-From- ASP.NET的数据库类 [ ^ ]-它可能无法完全满足您的需求,因为它假定图像实际上存储在数据库中,但是您应该可以轻松地进行修改以适合您的情况.
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.


这篇关于为什么照片未显示在网页中.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆