教學:如何動態加入user control ?
如果你已經有自己寫好的控制項, 又想要動態加入的話!!!
就用LoadControl("*.ascx") 就可以啦!
C# :
**************************************************
Control ucMode = LoadControl("XXX.ASCX");
this.FindControl("FORM").Controls.Clear();
this.FindControl("FORM").Controls.Add(ucMode);
**************************************************
VB :
**************************************************
Dim ucMode As Control = LoadControl("XXX.ASCX")
Me.FindControl("FORM").Controls.Clear()
Me.FindControl("FORM").Controls.Add(ucMode)
**************************************************
就用LoadControl("*.ascx") 就可以啦!
C# :
**************************************************
Control ucMode = LoadControl("XXX.ASCX");
this.FindControl("FORM").Controls.Clear();
this.FindControl("FORM").Controls.Add(ucMode);
**************************************************
VB :
**************************************************
Dim ucMode As Control = LoadControl("XXX.ASCX")
Me.FindControl("FORM").Controls.Clear()
Me.FindControl("FORM").Controls.Add(ucMode)
**************************************************
0 Comments:
張貼留言
<< Home