I am programatically creating (2) controls in code-behind ("btn" and "pnl"). btn is a
custom control that hides another control (clientside). When using these as static controls, it works great, however, here is the code for the code-behind.
code begin:
Button btn = new Button();
Panel pnl = new Panel();
btn.ControlToToggle = pnl;
end code
Everything is great except the ControlToToggle when a control is created programatically.
Because (pnl) hasn't been rendered yet, btn.ControlToToggle doesn't see a control on the page and give "Object not set to an instance..."
I have had the same problem in the past working with other "built in" controls.
My question is:
Is there a way to render a programatically created control to the page before it is posted back to the client?
Thanks