1
我試圖在代碼隱藏中爲我的控件創建一個updatepanel。但我得到以下錯誤:UpdatePanel代碼隱藏錯誤「頁面不能爲空」
頁面不能爲空。請確保此操作正在ASP.NET請求的上下文中執行。
我的代碼:
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
}
任何IDEIA?
感謝, 費爾南多
這是哪裏的代碼被稱爲?頁面生命週期的哪一部分?這是在自定義控件中還是來自頁面的代碼隱藏?什麼是「控制」? – 2010-04-18 12:21:33