欧美特黄不卡,涩涩视频在线,成人国产精品一区二区网站,亚洲一区二区三区欧美

當(dāng)前位置:雨林木風(fēng)下載站 > 技術(shù)開發(fā)教程 > 詳細頁面

ASP.NET中根據(jù)XML動態(tài)創(chuàng)建并運用WEB組件(二)

ASP.NET中根據(jù)XML動態(tài)創(chuàng)建并運用WEB組件(二)

更新時間:2022-05-09 文章作者:未知 信息來源:網(wǎng)絡(luò) 閱讀次數(shù):

ASP.NET中根據(jù)XML動態(tài)創(chuàng)建使用WEB組件

(二)

作者:厲鐵帥

三、動態(tài)創(chuàng)建WEB組件。

先來看程序?qū)嵗?br>
private void createconfigtable(int totalnum,int[] sequenceint,string[] namestr,string[] ipstr)

{

//根據(jù)得到測量點的總數(shù),動態(tài)生成輸入框

for(int i=1;i<=totalnum;i++)

{

//創(chuàng)建表格

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);

//創(chuàng)建一行

HtmlTableRow tRow = new HtmlTableRow();

showtable.Rows.Add(tRow);



//創(chuàng)建第一列(序號)

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);



//創(chuàng)建第二列

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;





//創(chuàng)建第三列(名稱)

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);



//創(chuàng)建第四列

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);



//創(chuàng)建第五列(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);



//創(chuàng)建第六列

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);

… …

//創(chuàng)建第五列(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);



//創(chuàng)建第六列

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>

… …



















使用該組件的目的是為了定位動態(tài)創(chuàng)建的表格。該組件在頁面上的位置即為動態(tài)創(chuàng)建的表格的位置。

程序中另外一個要說明的地方是動態(tài)創(chuàng)建的組件的ID的設(shè)定。組件的ID的設(shè)定要注意兩點:

1、ID號不能重復(fù)

2、要便于在程序中使用。因為要在程序中使用動態(tài)創(chuàng)建的組件,要通過該組件的ID來查找。(關(guān)于這一點,在“使用動態(tài)創(chuàng)建的WEB組件”部分會有較為詳

溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統(tǒng)下載排行

主站蜘蛛池模板: 贺州市| 巴林右旗| 阿克苏市| 高邑县| 乌鲁木齐市| 怀来县| 建水县| 崇文区| 宁安市| 彝良县| 阿克陶县| 永宁县| 遵义县| 都昌县| 浠水县| 宣化县| 和田市| 正镶白旗| 大关县| 正镶白旗| 太谷县| 瑞丽市| 离岛区| 冷水江市| 朝阳区| 灵武市| 镇原县| 白城市| 延庆县| 山东省| 大关县| 天津市| 江阴市| 察隅县| 乌苏市| 左权县| 敦煌市| 亚东县| 青海省| 本溪| 合川市|