That is because first all controls are loaded and then the button click is fired so you can do any of these:
1: Find the label in UC2 in your button click in UC1 and change the text like:
protected void Button1_Click(object sender, EventArgs e)
{
Label lbl = (Label)MyUC2.FindControl("Label1");
if (lbl != null)
{
lbl.Text = "NewValue";
}
}
Or
2: A Property in UC2 like below:
private string _myLabelText;
public string MyLabelText
{
get
{
return _myLabelText;
}
set
{
_myLabelText = value;
OnPropertyChanged(new PropertyChangedEventArgs("mylabeltext"));
}
}
private void OnPropertyChanged(PropertyChangedEventArgs propertyChangedEventArgs)
{
Label1.Text = this.MyLabelText;
}
and the button click will look like below:
protected void Button1_Click(object sender, EventArgs e)
{
MyUC2.MyLabelText = TextBox1.Text;
}