I created a new TestControl control. At the front end I gave him
<asp:Label ID="lblTest" runat="server" />
On server:
public partial class TestControl : System.Web.UI.UserControl { protected void Page_Load(object sender, EventArgs e) { lblTest.Text = "blah"; } }
When I load the control with:
var control1 = LoadControl(typeof(TestControl), null); Controls.Add(control1);
I get an exception that lblTest is null.
Why is this happening?
source share