我正在創建一個表格,代碼文件後面的代碼&將佔位符。表格單元格定位問題
//在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