将服务器图像嵌入HTML

将服务器图像嵌入HTML

本文介绍了将服务器图像嵌入HTML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我动态创建了一个HTML表,然后我想在该表的单元格中嵌入一个服务器映像,我这样做是-

I created an HTML table dynamically.Then I wanted to embed a server image in the cell of that table.I did so as-

HtmlTableCell c = new HtmlTableCell();
Image img = new Image();
img.ImageUrl = Server.MapPath("Images/red.jpg");
c.Controls.Add(img); 


但是当我执行此操作时,图像没有出现.
我在这里想念什么吗?

请提出建议.

在此先感谢!!
[edit]添加了代码块"Ingore HTML ..>"选项已禁用-OriginalGriff [/edit]


But when I execute this, the image is not appearing.
Am I missing something over here?

Please suggest.

Thanks in advance !!
[edit]Code block addded, "Ingore HTML..>" option disabled - OriginalGriff[/edit]

推荐答案

HtmlTable tab = new HtmlTable();
tab.Border = 1;
tab.BorderColor = "#cccccc";
HtmlTableRow tr = new HtmlTableRow();
HtmlTableCell c = new HtmlTableCell();
Image img = new Image();
img.ImageUrl=Page.ResolveClientUrl("~/Images/red.jpg");
img.Style.Add("width", "300px;");
img.Style.Add("height", "400px");
c.Controls.Add(img);
c.Style.Add("width", "300px;");
c.Style.Add("height", "400px;");
tr.Cells.Add(c);
tab.Rows.Add(tr);
form1.Controls.Add(tab);



如果我误解了您的问题,请随时纠正我.希望以上信息对您有所帮助.如果您还有其他顾虑,请告诉我.

如果这确实对您有帮助,请不要忘记投票并接受答案.



If i misunderstand your question, please feel free to correct me.I hope the above information will be helpful. If you have more concerns, please let me know.

If this would be really helpful to you then don''t forgot to Vote and Make Answer as Accepted.


HtmlTableCell c = new HtmlTableCell();

创建表单元格的新实例:thumbsup:

Creates a new instance of a table cell :thumbsup:

Image img = new Image();

创建一个新的图片控件. :thumbsup:

Creates a new image control. :thumbsup:

img.ImageUrl = Server.MapPath("Images/red.jpg");

将Image控件指向一个图像文件:thumbsup:

Points the Image control at an image file :thumbsup:

c.Controls.Add(img);

将图像添加到表格"单元格.
然后不使用表格单元格尝试显示它....:thumbsdown:

Adds the Image to the Table cell.:thumbsup:

And then does nothing with the table cell to try and display it....:thumbsdown:



这篇关于将服务器图像嵌入HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 04:53