c# - Why are my dynamically added user controls showing having their ascx controls as null? -
i created new control testcontrol
. on front-end gave it
<asp:label id="lbltest" runat="server" />
on backend:
public partial class testcontrol : system.web.ui.usercontrol { protected void page_load(object sender, eventargs e) { lbltest.text = "blah"; } }
when load control via:
var control1 = loadcontrol(typeof(testcontrol), null); controls.add(control1);
i exception lbltest
null.
why occurring?
use relative path overload of loadcontrol method instead, noted here.
http://msdn.microsoft.com/en-us/library/ewtd66a0.aspx
edit: changed answer after research.
Comments
Post a Comment