.aspx
<body MS_POSITIONING="GridLayout">
<form id="FormButton" method="post" runat="server">
<FONT id="FONT1" face="宋体">
<asp:panel id="Pel" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" runat="server"Width="704px" Height="224px"></asp:panel></FONT></form>
</body>
</HTML>
.cs
void page_load()
...
Label lbel;
Panel pnel;
System.Web.UI.WebControls.Image img;
System.Web.UI.WebControls.Image img1;
Panel pnel1;
for(int i=0; i<ds.Tables["t_tree"].Rows.Count; i++ )
{
pnel=new Panel();
pnel.ID="MenuImageButton"+Convert.ToString(i)+"_theDiv";
pnel.Style.Add("Z-INDEX","1" );
pnel.Style.Add("VISIBILITY", "visible");
pnel.Style.Add("BEHAVIOR", "url(htc.htc)");
pnel.Style.Add("POSITION", "absolute");
img=new System.Web.UI.WebControls.Image();
img.ID="MenuImageButton"+Convert.ToString(i)+"_theImage";
img.ImageUrl="images/folder.png";
img.Style.Add("Z-INDEX", "1");
img.Style.Add("POSITION", "absolute");
pnel.Controls.Add(img);
img1=new System.Web.UI.WebControls.Image();
img1.ID="MenuImageButton"+Convert.ToString(i)+"_theMask";
img1.ImageUrl="images/folder.png";
img1.Style.Add("Z-INDEX", "3");
img1.Style.Add("FILTER","");
img1.Style.Add("progid","DXImageTransform.Microsoft.MaskFilter(color=Window)");
img1.Style.Add("VISIBILITY", "hidden");
img1.Style.Add("POSITION"," absolute");
pnel.Controls.Add(img1);
pnel1=new Panel();
pnel1.ID="MenuImageButton"+Convert.ToString(i)+"_theShadow";
pnel1.Style.Add("Z-INDEX", "2");
pnel1.Style.Add("FILTER","");
pnel1.Style.Add("progid","DXImageTransform.Microsoft.Alpha(opacity=50)");
pnel1.Style.Add("VISIBILITY", "hidden");
pnel1.Style.Add("POSITION"," absolute");
pnel1.Style.Add("BACKGROUND-COLOR"," highlight");
pnel.Controls.Add(pnel1);
lbel=new Label();
lbel.ID="MenuImageButton"+Convert.ToString(i)+"_theLabel";
lbel.Style.Add("POSITION"," absolute");
lbel.Text=ds.Tables["t_tree"].Rows[i]["nodename"].ToString();
pnel.Controls.Add(lbel);
}
}
现在这样做显示出来的image 和label 都重叠在一块了。怎么解决。谢谢!

解决方案 »

  1.   

    可以table ,tablecell,tablerow来控制。
    将控件放在cell中。
      

  2.   

    我就是不想放在table中,可有办法实现。
      

  3.   

    pnl.Controls.Add(new LiteralControl("<table>"));
    pnl.Controls.Add(new LiteralControl("<tr>"));
    pnl.Controls.Add(new LiteralControl("<td>"));
    ...
    pnl.Controls.Add(new LiteralControl("</td>"));
    pnl.Controls.Add(new LiteralControl("</tr>"));
    pnl.Controls.Add(new LiteralControl("</table>"));
      

  4.   

    用table怎么控制。能针对我上面的代码,来个例子吗?能用datalist吗。