I am currently trying to write a custom webpart which loads a
usercontrol in the CreateChildControls method.
My webpart has a property which I would like to assign to a property
in the usercontrol.
Here's the code:
protected override void CreateChildControls()
{
MyCustomControl x =
Page.LoadControl("~/_controltemplates/Custom/MyCustomControl.ascx") as
MyCustomControl;
x.CustomProperty = _CustomPropertyFromWebPart; //error here
this.Controls.Add(x);
}
The error I get is "Object reference not set to instance of an object"
when trying to assign the property (based on attaching to the worker
process).