I have a UserControl
that functions as a template for a FormView
, But depending on whether it is in edit or insert mode, one of the TextBox
controls needs to be disabled. I added a function to the UserControl
public bool IsInsert
{
get { return txtUser.Enabled; }
set { txtUser.Enabled = value; }
}
But I cannot get a reference of the UserControl
in the parent's Page_Load
event. I defined the control in the aspx code (not code-behind). I've tries using FindControl
but I get an error Object reference not set to an instance of an object
. Is this because the UserControl
loads after the page? Is there another method of disabling the TextBox
conditionally?