ASP.NET中根据XML动态创建使用WEB组件 (2)
点击次数:20 次 发布日期:2008-11-26 13:52:59 作者:源代码网
|
源代码网推荐 (二) 源代码网推荐 源代码网推荐 作者:厉铁帅 源代码网推荐 源代码网推荐 三、动态创建WEB组件。 源代码网推荐 源代码网推荐 先来看程序实例: 源代码网推荐 源代码网推荐 private void createconfigtable(int totalnum,int[] sequenceint,string[] namestr,string[] ipstr) 源代码网推荐 源代码网推荐 { 源代码网推荐 源代码网推荐 //根据得到测量点的总数,动态生成输入框 源代码网推荐 源代码网推荐 for(int i=1;i<=totalnum;i++) 源代码网推荐 源代码网推荐 { 源代码网推荐 源代码网推荐 //创建表格 源代码网推荐 源代码网推荐 HtmlTable showtable = new HtmlTable(); 源代码网推荐 源代码网推荐 showtable.Border=0; 源代码网推荐 源代码网推荐 showtable.ID="showtable"+i.ToString(); 源代码网推荐 源代码网推荐 showtable.BorderColor="#000000"; 源代码网推荐 源代码网推荐 showtable.CellPadding=4; 源代码网推荐 源代码网推荐 showtable.CellSpacing=4; 源代码网推荐 源代码网推荐 showtable.Align="center"; 源代码网推荐 源代码网推荐 myPlaceHolder.Controls.Add(showtable); 源代码网推荐 源代码网推荐 //创建一行 源代码网推荐 源代码网推荐 HtmlTableRow tRow = new HtmlTableRow(); 源代码网推荐 源代码网推荐 showtable.Rows.Add(tRow); 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 //创建第一列(序号) 源代码网推荐 源代码网推荐 HtmlTableCell tCell = new HtmlTableCell(); 源代码网推荐 源代码网推荐 Label sequenceLabel = new Label(); 源代码网推荐 源代码网推荐 sequenceLabel.ID="sequenceLabel"+i.ToString(); 源代码网推荐 源代码网推荐 sequenceLabel.Text="序号:"; 源代码网推荐 源代码网推荐 sequenceLabel.Enabled=true; 源代码网推荐 源代码网推荐 tCell.Controls.Add(sequenceLabel); 源代码网推荐 源代码网推荐 tRow.Cells.Add(tCell); 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 //创建第二列 源代码网推荐 源代码网推荐 tCell = new HtmlTableCell(); 源代码网推荐 源代码网推荐 sequencedataTB = new TextBox(); 源代码网推荐 源代码网推荐 sequencedataTB.ID="sequencedataTB"+i.ToString(); 源代码网推荐 源代码网推荐 sequencedataTB.Text=i.ToString(); 源代码网推荐 源代码网推荐 sequencedataTB.Width=30; 源代码网推荐 源代码网推荐 sequencedataTB.Text=sequenceint[i].ToString(); 源代码网推荐 源代码网推荐 sequencedataTB.ReadOnly=false; 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 //创建第三列(名称) 源代码网推荐 源代码网推荐 tCell = new HtmlTableCell(); 源代码网推荐 源代码网推荐 Label nameLabel = new Label(); 源代码网推荐 源代码网推荐 nameLabel.ID="nameLabel"+i.ToString(); 源代码网推荐 源代码网推荐 nameLabel.Text="名称:"; 源代码网推荐 源代码网推荐 nameLabel.Enabled=true; 源代码网推荐 源代码网推荐 tCell.Controls.Add(nameLabel); 源代码网推荐 源代码网推荐 tRow.Cells.Add(tCell); 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 //创建第四列 源代码网推荐 源代码网推荐 tCell = new HtmlTableCell(); 源代码网推荐 源代码网推荐 nameTB=new TextBox(); 源代码网推荐 源代码网推荐 nameTB.ID="nameTB"+i.ToString(); 源代码网推荐 源代码网推荐 nameTB.Width=120; 源代码网推荐 源代码网推荐 nameTB.Text=namestr[i]; 源代码网推荐 源代码网推荐 nameTB.MaxLength=50; 源代码网推荐 源代码网推荐 tCell.Controls.Add(nameTB); 源代码网推荐 源代码网推荐 tRow.Cells.Add(tCell); 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 //创建第五列(IP) 源代码网推荐 源代码网推荐 tCell = new HtmlTableCell(); 源代码网推荐 源代码网推荐 Label ipLabel = new Label(); 源代码网推荐 源代码网推荐 ipLabel.ID="ipLabel"+i.ToString(); 源代码网推荐 源代码网推荐 ipLabel.Text="IP:"; 源代码网推荐 源代码网推荐 ipLabel.Enabled=true; 源代码网推荐 源代码网推荐 tCell.Controls.Add(ipLabel); 源代码网推荐 源代码网推荐 tRow.Cells.Add(tCell); 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 //创建第六列 源代码网推荐 源代码网推荐 tCell = new HtmlTableCell(); 源代码网推荐 源代码网推荐 ipTB=new TextBox(); 源代码网推荐 源代码网推荐 ipTB.ID="ipTB"+i.ToString(); 源代码网推荐 源代码网推荐 ipTB.Width=120; 源代码网推荐 源代码网推荐 ipTB.Text=ipstr[i]; 源代码网推荐 源代码网推荐 ipTB.MaxLength=15; 源代码网推荐 源代码网推荐 tCell.Controls.Add(ipTB); 源代码网推荐 源代码网推荐 tRow.Cells.Add(tCell); 源代码网推荐 源代码网推荐 } 源代码网推荐 源代码网推荐 } 源代码网推荐 源代码网推荐 tCell.Controls.Add(sequencedataTB); 源代码网推荐 源代码网推荐 tRow.Cells.Add(tCell); 源代码网推荐 源代码网推荐 … … 源代码网推荐 源代码网推荐 //创建第五列(IP) 源代码网推荐 源代码网推荐 tCell = new HtmlTableCell(); 源代码网推荐 源代码网推荐 Label ipLabel = new Label(); 源代码网推荐 源代码网推荐 ipLabel.ID="ipLabel"+i.ToString(); 源代码网推荐 源代码网推荐 ipLabel.Text="IP:"; 源代码网推荐 源代码网推荐 ipLabel.Enabled=true; 源代码网推荐 源代码网推荐 tCell.Controls.Add(ipLabel); 源代码网推荐 源代码网推荐 tRow.Cells.Add(tCell); 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 //创建第六列 源代码网推荐 源代码网推荐 tCell = new HtmlTableCell(); 源代码网推荐 源代码网推荐 ipTB=new TextBox(); 源代码网推荐 源代码网推荐 ipTB.ID="ipTB"+i.ToString(); 源代码网推荐 源代码网推荐 ipTB.Width=120; 源代码网推荐 源代码网推荐 ipTB.Text=ipstr[i]; 源代码网推荐 源代码网推荐 ipTB.MaxLength=15; 源代码网推荐 源代码网推荐 tCell.Controls.Add(ipTB); 源代码网推荐 源代码网推荐 tRow.Cells.Add(tCell); 源代码网推荐 源代码网推荐 } 源代码网推荐 源代码网推荐 } 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 程序中的myPlaceHolder 是 System.Web.UI.WebControls.PlaceHolder 组件,使用该组件的HTML语法如下: 源代码网推荐 源代码网推荐 … … 源代码网推荐 源代码网推荐 <tr> 源代码网推荐 源代码网推荐 <td> 源代码网推荐 源代码网推荐 <asp:PlaceHolder id="myPlaceHolder" runat="server"></asp:PlaceHolder> 源代码网推荐 源代码网推荐 </td> 源代码网推荐 源代码网推荐 </tr> 源代码网推荐 源代码网推荐 … … 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 源代码网推荐 使用该组件的目的是为了定位动态创建的表格。该组件在页面上的位置即为动态创建的表格的位置。 源代码网推荐 源代码网推荐 程序中另外一个要说明的地方是动态创建的组件的ID的设定。组件的ID的设定要注意两点: 源代码网推荐 源代码网推荐 1、ID号不能重复 源代码网推荐 源代码网推荐 2、要便于在程序中使用。因为要在程序中使用动态创建的组件,要通过该组件的ID来查找。(关于这一点,在“使用动态创建的WEB组件”部分会有较为详细的介绍) 源代码网推荐 做人要厚道,请注明转自酷网动力(www.ASPCOOL.COM)。 源代码网推荐 源代码网供稿. |
