I have two usercontrol UC_1.ascx & Uc_2.ascx.
I tried to bind UC_2 textbox values from my UC_1.
Below is my code :
System.Web.UI.UserControl UserControl1 = (System.Web.UI.UserControl)Page.FindControl("UC_2");
if (UserControl1 != null)
{
TextBox txt = UserControl1.FindControl("txtTest") as TextBox; //thwon object null reference error.
txt.Text = "test123123123213";
}
But I am getting error from calling UserControl1
object.
Error like :
Object reference not set to an instance of an object.