I dynamically load a UC in the Oninit of the host page.
In the Oninit of the UC, I raise an event. I get a null reference exception. The code is as below:
//In the UC
public event CommandEventHandler DoneProcessing;
protected override void OnInit(EventArgs e)
{
//Raise a event
CommandEventArgs cmdEventArgs = new CommandEventArgs("done", "test");
DoneProcessing(this, cmdEventArgs);
}
When I raise the event in Page Load instead of Oninit, it works fine, but I cannot do this since I have to load a child control and for things to work correctly (viewstate etc), I need to do this on OnInit.