我正在创建一个表格,代码文件后面的代码&将占位符。表格单元格定位问题
//在Main.aspx
MyControl control1 = (MyControl)Page.LoadControl("MyControl.ascx");
control1.ID = "ctl1";
MyControl control2 = (MyControl)Page.LoadControl("MyControl.ascx");
control2.ID = "ctl2";
MyControl control3 = (MyControl)Page.LoadControl("MyControl.ascx");
control3.ID = "ctl3";
MyControl control4 = (MyControl)Page.LoadControl("MyControl.ascx");
control4.ID = "ctl4";
Table table = new Table();
TableCell cell1 = new TableCell();
TableCell cell2 = new TableCell();
TableCell cell3 = new TableCell();
TableCell cell4 = new TableCell();
TableRow row1 = new TableRow();
table.Style.Add(HtmlTextWriterStyle.Position, "absolute");
cell1.Controls.Add(control1);
row1.Cells.Add(cell1);
cell1.Style.Add(HtmlTextWriterStyle.Position, "absolute");
cell2.Controls.Add(control2);
row1.Cells.Add(cell2);
cell2.Style.Add(HtmlTextWriterStyle.Position, "absolute");
cell3.Controls.Add(control3);
row1.Cells.Add(cell3);
cell3.Style.Add(HtmlTextWriterStyle.Position, "absolute");
cell4.Controls.Add(control4);
row1.Cells.Add(cell4);
cell4.Style.Add(HtmlTextWriterStyle.Position, "absolute");
table.Rows.Add(row1);
placeHolder1.Controls.Add(table);
//在MyControl.ascx(在这里,我将控制;其与JavaScript创建)
<table cellpadding="0" cellspacing="0" border="0" width="217px"
style="position:relative" >
<tr>
<td >
<div id="c1" class="gauge" style="margin:0;padding:0;height:169px;width:217px;">
</div>
</td>
</tr>
//在用户控制的CSS中
div.gauge
{
background-repeat: no-repeat;
background-position: top center;
height: 169px;
margin: 0px;
overflow: visible;
position: absolute;
width: 217px;
z-index: 0;
}
但是我看到只有第一个控件被加载,其他的没有。有什么遗漏?
谢谢你的时间。实际上我使用这个尺寸:http://www.dariancabot.com/projects-2/jgauge/由于它是用多层创建的,因此每个图层都有不同的z索引。 – benjamin54