在ASP TABLE中显示图像 [英] Displaying an image in an ASP TABLE

查看:90
本文介绍了在ASP TABLE中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在从事一个电子商务学院的项目.我想在其中显示类别中所有产品的列表.为此,我决定我将在asp表单元格中显示图像.在运行时,我正在使用img src froc数据库并将其添加到单元格中.文字

Hi All,

I am working on a e- commerce college project. In which i want to show list of all product in a category. for that i have decided that i will show image in a asp table cell. At runtime i am taking img src froc database and adding it to cell. text

   c0.Text = "<img src=\"" + Convert.ToString(dvSql.Table.Rows[i][0]) + "\"/ ><br/>" + Convert.ToString(dvSql.Table.Rows[i][1]) + "<br/>" + Convert.ToString(dvSql.Table.Rows[i][2]) + "<br/>" + Convert.ToString(dvSql.Table.Rows[i][3]);
 row.Cells.Add(c0);
Table1.Rows.Add(row);



字符串值可以在页面上正常打印,但是没有图像可用于img控制.从浏览器检查网页的来源时,它会显示正确的值,如下所示.



The string values are getting printed okay on the page, but no images are coming for img control. On checking source of webpage from the browser it shows correct values which is shown below.

<tr>
		<td><img src="D:\WebSite\Working code\Email.thebustles.com\Products\Apperal\images\perfume1.jpg"/ ><br/>Samsung Wave<br/>Samsung<br/>200</td>



请帮助我..::(我没有任何线索



please help me .. :( i am getting no clues

推荐答案



也许这会有所帮助:
http://stackoverflow.com/questions/4090712/why- cant-i-do-img-src-c-localfile-jpg [
Hi,

Maybe this will help:
http://stackoverflow.com/questions/4090712/why-cant-i-do-img-src-c-localfile-jpg[^]

The image files have to be on your web server and then referenced by a url like:
<img src="www.mydomain.com/myimg.jpg" />


而且您实际上不需要写域名.如果图像与网页位于同一文件夹中,则可以编写:


And you actually don''t need to write the domain name. If the image is in the same folder as the web page you can write:

<img src="myimg.jpg" />



问候
Joachim



Regards
Joachim


我认为我之前从未为图像源做过完全合格的物理定位工作,所以我不确定是否可以做到.

您可能需要做的就是根据项目所在的页面来指定图像的位置.更改图像元素以改为使用相对路径.例如(仅作为示例)src ="../../images/myimage",它告诉页面它需要向上两个目录,然后在images文件夹中查找,然后找到myImage.

从一个示例开始,现在删除您对src的数据调用.这是我在项目中如何找到相对路径的方法.

Page.ResolveUrl(〜/Products/Apperal/Images/perfume1.jpg")

假设您的项目的网址库是email.thebustles.com,则将产生:email.thebustles.com/Products/Apperal/Images/perfume1.jpg.这意味着您甚至不必担心基于页面位置的相对路径(这可能会令人沮丧),并让页面为您解决. tilda(〜)表示从根文件夹开始,然后从那里开始(仅到asp.net).

一旦工作,您就可以尝试再次合并您的数据源.当然,您必须将数据库值更改为类似于〜/Products/Apperal/Images/perfume1.jpg"
I don''t think I''ve ever done a fully qualified physical location for an image source before... so I''m not sure it can be done.

What you probably need to do is give the image''s position based on the page you are on in your project. Change the image element to use an relative path instead. For example (only for example) src="../../images/myimage", which tells the page it needs to go up two directories, then look in the images folder, then find myImage.

Start with an example and remove your data call for the src for now. Here is how I would find the relative path in my projects.

Page.ResolveUrl("~/Products/Apperal/Images/perfume1.jpg")

Assuming that your project''s Url base is email.thebustles.com, this would yield: email.thebustles.com/Products/Apperal/Images/perfume1.jpg. Meaning this will allow you to not even worry about the relative path based on the page''s location (which can be frustrating) and let the page figure it out for you. The tilda (~) means start with the root folder and work from there (only to asp.net).

Once that''s working, then you can try to incorporate your datasource again. Of course, you''ll have to change the database values to look like "~/Products/Apperal/Images/perfume1.jpg"


这篇关于在ASP TABLE中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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