Adding Multiple Control to an Update Panel

dolphinradar

New Member
when I add one control to an update panel, it works just fine. Actually, on a button click I add 2 controls at once, a panel and a juice ui draggable control which allows me to move the panel around the page. but when I try to add a second control it deletes the first one. I add the controls to a Control List first, then cycle through the list and add each control to the update panel. but the list doesnt add the second set of controls, the count of the list always remains at two. the code is as follows:\[code\] currentControlsInUpdatePanel.Add(panel); currentControlsInUpdatePanel.Add(drag); Label1.Text = currentControlsInUpdatePanel.Count.ToString(); foreach (Control ctl in currentControlsInUpdatePanel) { upForm.ContentTemplateContainer.Controls.Add(ctl); }\[/code\]the entire code\[code\]List<Control> currentControlsInUpdatePanel = new List<Control>(); int panelCounter = 0;on the button click: Panel panel = new Panel(); panel.ID = "panel" + panelCounter.ToString(); panel.Attributes.Add("class", "box ui-draggable"); panel.Attributes.Add("data-ui-widget", "draggable"); panel.CssClass = "panelControl"; Juice.Draggable drag = new Juice.Draggable(); drag.ID = "drag" + panelCounter.ToString(); drag.TargetControlID = panel.ID; Label lbl = new Label(); lbl.ID = txtControlLabel.Text; lbl.Text = txtControlLabel.Text; lbl.CssClass = "controlLabel"; panel.Controls.Add(lbl); currentControlsInUpdatePanel.Add(panel); currentControlsInUpdatePanel.Add(drag); Label1.Text = currentControlsInUpdatePanel.Count.ToString(); foreach (Control ctl in currentControlsInUpdatePanel) { upForm.ContentTemplateContainer.Controls.Add(ctl); } panelCounter++;\[/code\]
 
Back
Top