I have an aspx page with declared placeholder control.
In Codebehind, I create a UserControl that I have and add it to the Placeholder.
protected void Page_Load(object sender, EventArgs e) { UserControl uc = new ChartUserControl(); myForm.Controls.Add(uc); }
The UserControl user, in turn, has a Placeholder, but in Page_Load (for UserControl), when I do this:
protected void Page_Load(object sender, EventArgs e) { WebControl x = new WebControl(); userControlPlaceholder.Controls.Add(x); }
This gives me the ubiquitous exception, "An object reference not set to an instance of an object."
I tried to create an instance by calling the constructor, but this caused me other problems. Any help would be appreciated.
source share