Hi guys, i'm trying create a updatepanel for my controls in a codebehind. But i get the follow error:
Page cannot be null. Please ensure that this operation is being performed in the context of an ASP.NET request.
My code:
List<Control> novoControl = new List<Control>();
control.Controls.ForEach<Control>(c => novoControl.Add(c));
control.Controls.Clear(); // This control is a contentplaceholder of my masterpage
control.Controls.Add(IcpScriptManager); //Add ScriptManager in the page
foreach (Control item in novoControl)
{
UpdatePanel up = new UpdatePanel();
up.ID = "up_" + item.ID;
up.ChildrenAsTriggers = true;
up.UpdateMode = UpdatePanelUpdateMode.Conditional;
up.ContentTemplateContainer.Controls.Add(item);
control.Controls.Add(up); //ERROR happens here
}
Any ideia??
Thanks, Fernando