표준 Load 이벤트의 링크를 제공
대답은 잘 발생한다. 표준 ASP.Net 컨트롤 이벤트는 usercontrols에 대해 제기됩니다. 상위 페이지에서 사용자 정의 컨트롤 내부의 이벤트를 발생 시키려면 다음과 같은 작업을 수행해야합니다.
사용자 정의 컨트롤에서 이벤트를 생성하고 연결합니다. 이 예에서는 내가를 Page_Load에서 호출 할 수 있습니다 :
public event EventHandler TestEvent;
protected void Page_Load(object sender, EventArgs e)
{
if (this.TestEvent != null)
{
this.TestEvent(this, e);
}
}
을 부모 페이지 와이어 최대 사용자의 내부 것은 TestEvent을 제어합니다 도움이
protected override void OnInit(EventArgs e)
{
MyUserControl uc = LoadControl("~/PathToUserControl.ascx");
uc.TestEvent += new EventHandler(MyUserControl_TestEvent);
}
protected void MyUserControl_TestEvent(object sender, EventArgs e)
{
//this code will execute when the usercontrol's Page_Load event is fired.
}
희망!
죄송합니다. 이벤트가 발생하지 않습니다. – Podge