国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

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

2024-07-10 12:57:18
字體:
供稿:網(wǎng)友

最大的網(wǎng)站源碼資源下載站,

asp.net中根據(jù)xml動(dòng)態(tài)創(chuàng)建使用web組件

(二)

作者:厲鐵帥

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

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

{

//根據(jù)得到測(cè)量點(diǎn)的總數(shù),動(dòng)態(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)建第一列(序號(hào))

htmltablecell tcell = new htmltablecell();

label sequencelabel = new label();

sequencelabel.id="sequencelabel"+i.tostring();

sequencelabel.text="序號(hào):";

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>

… …



















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

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

1、id號(hào)不能重復(fù)

2、要便于在程序中使用。因?yàn)橐诔绦蛑惺褂脛?dòng)態(tài)創(chuàng)建的組件,要通過該組件的id來查找。(關(guān)于這一點(diǎn),在“使用動(dòng)態(tài)創(chuàng)建的web組件”部分會(huì)有較為詳細(xì)的介紹)
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 克东县| 四川省| 正镶白旗| 绥滨县| 淳安县| 丹江口市| 谢通门县| 苗栗市| 张家界市| 西丰县| 砚山县| 抚远县| 铜川市| 调兵山市| 博客| 嘉义县| 南投县| 东光县| 怀远县| 连城县| 石渠县| 杭州市| 通榆县| 温州市| 永昌县| 佛坪县| 封开县| 潜山县| 二手房| 鄂州市| 右玉县| 商水县| 禄劝| 喀喇沁旗| 合山市| 铜梁县| 郴州市| 淳安县| 三原县| 长丰县| 南京市|