如何定位动态生成的textbox,在整个页面上?
如何定位动态生成的textbox,在整个页面上?
推荐阅读
findcontrol("id")
style属性的top,left
textbox tb = (textbox)this.findcontrol("txt" + 1);
page.controls.add(textbox);
利用panel,把动态生的控件装载进去
http://expert.csdn.net/expert/topic/2146/2146645.xml?temp=.4301111
参考这个网页,
跟我问的问题差不多。
在页面上先放一个表menutable:
for(int j =0;j<8;j++){
tablerow r = new tablerow();
int numcells = 4;
for (int i=0; i<numcells; i++)
{
tablecell c = new tablecell();
c.horizontalalign = horizontalalign.center;
c.height = (unit)25;
c.font.bold=true;
c.attributes.add("onmouseover", "this.style.backgroundcolor=lightgoldenrodyellow");
c.attributes.add("onmouseout", "this.style.backgroundcolor=lightblue");
c.style["cursor"] = "hand";
c.forecolor=color.blue;
textbox tb = new textbox();
tb.id="dd";
tb.text="aa";
c.controls.add(tb);
r.cells.add(c);
}
menutable.rows.add(r);
}
在你想放置控件的位置放上一个placeholder
使用placeholder来加载控件
tablerow r = new tablerow();
int numcells = 4;
for (int i=0; i<numcells; i++)
{
tablecell c = new tablecell();
c.horizontalalign = horizontalalign.center;
c.height = (unit)25;
c.font.bold=true;
c.attributes.add("onmouseover", "this.style.backgroundcolor=lightgoldenrodyellow");
c.attributes.add("onmouseout", "this.style.backgroundcolor=lightblue");
c.style["cursor"] = "hand";
c.forecolor=color.blue;
r.cells.add(c);
}
menutable.rows.add(r);
for(int j =0;j<8;j++){
tablerow r = new tablerow();
int numcells = 4;
for (int i=0; i<numcells; i++)
{
tablecell c = new tablecell();
c.horizontalalign = horizontalalign.center;
c.height = (unit)25;
c.font.bold=true;
c.attributes.add("onmouseover", "this.style.backgroundcolor=lightblue");
c.attributes.add("onmouseout", "this.style.backgroundcolor=white");
c.style["cursor"] = "hand";
c.forecolor=color.blue;
textbox tb = new textbox();
tb.id="dd";
if(i == 3)
tb.text="aa";
if(i== 1)
tb.text="hh";
else
tb.text="ui";
c.controls.add(tb);
r.cells.add(c);
}
menutable.rows.add(r);
}


讨论区