当前位置: 代码迷 >> ASP.NET >> 动态加载Image控件的有关问题!
  详细解决方案

动态加载Image控件的有关问题!

热度:2646   发布时间:2013-02-26 00:00:00.0
动态加载Image控件的问题!!!!!
前台: <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;
  相关解决方案