I have a website with a master page and several content pages. One of the content page has a usercontrol. I want to set the text property of a lebel in the usercontrol from the parent page. I tried two methods of doing it. First I got the instance of the usercontrol and tried to access the label control using the FindControl method. But I always got "Object reference not set to an instance of an object". Next I created a public property on the usercontrol and tried to set its value from the parent page. But I didn't see the property in the intellisence to set it.
Code behind in the parent page:
protected void Page_Load(object sender, EventArgs e)
{
UserControl contactEmail = FindControl("contactEmail") as UserControl;
Label lblDisplay = (Label)contactEmail.FindControl("lblDisplay");
lblDisplay.Text = "Please Contact Us";
}
User control html code: ...
Go to the complete details ...