Monday, July 5, 2010

Delegate using in ASPX Page and user control

In ASPX Page :

public partial class Activity_ContactActivity : Page
{
protected void Page_Load(object sender, EventArgs e)
{
MonthActivity1.LoadWeekTabInformation += new UserControls_Activity_MonthActivity.LoadTabInformation(MonthActivity1_LoadWeekTabInformation);
}

void MonthActivity1_LoadWeekTabInformation()
{
this.ActivityDate = MonthActivity1.ActivityDate;
this.CurrentActivityTab = enumContactActivityTab.Week;
LoadActivityInformation();
}
}


In User Control Page :

public partial class UserControls_Activity_MonthActivity : UserControl
{
public delegate void LoadTabInformation();
public event LoadTabInformation LoadWeekTabInformation;

private void DisplayWeekTabInformation()
{
LoadWeekTabInformation();
}
}

No comments: