作者hirabbitt (兔子)
看板Web_Design
标题[问题] ASP.NET postback後抓不到Control
时间Thu Feb 9 18:21:19 2017
public DropDownList ddl;
protected void Page_LoadComplete(object sender, EventArgs e)
{
ddl = new DropDownList();
ddl.ID = "ID";
node.Controls.Add(ddl); // node is a TableCell
}
//<asp:TextBox
// AutoPostBack="true" OnTextChanged="OnTextChanged" runat="server">
//</asp:TextBox>
protected void OnTextChanged(object sender, EventArgs e)
{
DropDownList tmpDDL1 = ddl; // null
DropDownList tmpDDL2 = FindControl("ID"); // null
DropDownList tmpDDL3 = node.FindControl("ID"); // null
DropDownList tmpDDL4 = this.FindControl("ID"); // null
DropDownList tmpDDL5 = this.Page.FindControl("ID"); // null
DropDownList tmpDDL6 = fnFindControlRecursive(this, "ID"); // null
}
在画面上还是看得到这个DDL
只是我抓不到它
想要给它设selected该怎麽办呢
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 211.75.101.50
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Web_Design/M.1486635688.A.533.html
1F:→ ssccg: control的event在LoadComplete前面,所以没有 02/09 20:30
2F:→ hirabbitt: 咦对耶 那我写到Init去好了 02/10 08:51
3F:→ te426odin: 有C#版喔! 02/10 09:16
4F:→ hirabbitt: 好喔 02/10 11:33