Finding Controls in an Update Panel

kotoyamu3

New Member
I have seen a few threads on this. if I have a control in an update panel when the page loads, I can easily get it with the following code:\[code\] Label lbls = (Label)upPreview.FindControl(lbl.ID); lbls.Text = lbl.ID;\[/code\]What I cannot do is the following on two different buttons with two different update panelsButton 1:\[code\] Label lbl = new Label(); lbl.Text = "something"; lbl.ID = "something"; upPreview.ContentTemplateContainer.Controls.Add(lbl);\[/code\]Button 2\[code\] Label lbls = (Label)upPreview.FindControl(lbl.ID); lbls.Text = lbl.ID; upForm.ContentTemplateContainer.Controls.Add(lbls);\[/code\]essentially I am creating a label and putting it in one update panel, then on the second button click I am moving it to another update panel. every time I try this, it says:Value cannot be null.Parameter name: childI have also tried ControlCollection cbb = upPreview.ContentTemplateContainer.Controls;same error. any ideas?
 
Back
Top