Before adding any new control in your container control(like
Page
,
Panel
...), You have to make sure that the control is exists or not. How ?
public bool IsControlExists(Control container, string controlID) {
if (container != null && container.HasControls())
if (container.FindControl(controlID) != null)
return true;
return false;
}
So before adding any control in you container control, make sure to check existence by calling this method.
I hope this helps you well.