0
votes

I have a form and in the form I am adding and removing user controls depending on what is selected. There is a form that has two labels, the labels information is supposed to change when the user control loads but it never changes, it keeps the same values. Now, I added a break point on the load of the user control.. and it is only hit once, all the other times it just navigates there but never loads again..

private void SummaryScreen_OnLoad(object sender, EventArgs e)
{
    lblSavingsBalance.Text = Global.Instance.Accounts[1].AccountBalace.ToString();
    lblCheckingBalance.Text = Global.Instance.Accounts[0].AccountBalace.ToString();
}

How can I make it so that it loads all the time when i call this user control?

2
You are talking about the UserControl's OnLoad? (UserControl is called SummaryScreen?)John Arlen
yes the user control is called SummaryScreen - yes onload of SummaryScreen it only gets hit onceuser710502

2 Answers

2
votes

UserControl.Load is only called the first time it is added to a form after construction.

You will need to either:

  • Recreate the control each time (therefore forcing Load to be called)
  • Add a new method on the UserControl (like Initialize) and call it after adding
0
votes

probably it is caching use :-

 Response.Cache.SetCacheability(HttpCacheability.NoCache);
        Response.ExpiresAbsolute = DateTime.Now.AddMonths(-1); 

in your load function