I have a composite control that adds a TextBox and Label control to its Controls collection. When I try to set the Label AssociatedControlID to ClientID in a text box, I get this error
Unable to find control with id
'ctl00_MainContentPlaceholder_MatrixSetControl_mec50_tb'
that is associated with the Label 'lb'.
Ok, so a bit of background. I got this basic composite control that dynamically adds a few “elements” to my control collection. One of these elements is the "MatrixTextBox", which is a control consisting of a TextBox and a label.
I store Label and TextBox as protected class variables and run them in CreateChildControls:
ElementTextBox = new TextBox();
ElementTextBox.ID = "tb";
Controls.Add(ElementTextBox);
ElementLabel = new Label();
ElementLabel.ID = "lb";
Controls.Add(ElementLabel);
I tried to install
ElementLabel.AssociatedControlID = ElementTextBox.ClientID;
Controls PreRender - . ?