호스트 페이지의 Oninit에서 동적으로 UC를로드합니다.동적으로로드 된 사용자 정의 컨트롤에서 이벤트 발생시키기
UC의 Oninit에서 이벤트를 발생시킵니다. null 참조 예외가 발생합니다. 코드는 다음과 같습니다 :
//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);
}
내가 대신하는 OnInit의 페이지로드에서 이벤트를 발생시킬 때, 잘 작동하지만 자식 컨트롤을로드 할 수 있기 때문에 나는이 작업을 수행 할 수 viewstate가 (상황이 제대로 작동하려면 등), 나는 이것을 OnInit에서 할 필요가있다.