前台: <div align= "center " id= "imgDiv " runat=server> </div>
后台:
if (drow[ "ActiveImg1 "].ToString() != " ")
{
imgDiv.Controls.Add(img1);
img1.ImageUrl = "~/download/ " + drow[ "ActiveImg1 "].ToString();
}
else
img1.Dispose();
if (drow[ "ActiveImg2 "].ToString() != " ")
{
imgDiv.Controls.Add(img2);
img2.ImageUrl = "~/download/ " + drow[ "ActiveImg1 "].ToString();
}
else
img2.Dispose();
img1是Image控件,这样显示出来后两个图片是连起的,成了一行。
有什么办法可以让两张图片换行?
------解决方案--------------------------------------------------------
System.Web.UI.HtmlControls.HtmlTable t = new HtmlTable();
System.Web.UI.HtmlControls.HtmlTableRow tr = new HtmlTableRow();
System.Web.UI.HtmlControls.HtmlTableCell tc = new HtmlTableCell();
tc.Height= "20px ";
tc.InnerHtml = " <br/> ";
tr.Height = "20px ";
tr.Controls.Add(tc);
t.Height = "20px ";
t.Rows.Add(tr);
imgDiv.Controls.Add(t);
imgDiv.Controls.Add(img2);
img2.ImageUrl = strImg2;