2008-10-27 144 views
12

我有一個包含UpdatePanel的UserControl。當我把一個頁面上,它引發以下錯誤:什麼原因導致'無法取消註冊UpdatePanel'錯誤?

Cannot unregister UpdatePanel with ID 'ReviewContentUpdatePanel' since it was not registered with the ScriptManager. This might occur if the UpdatePanel was removed from the control tree and later added again, which is not supported. Parameter name: updatePanel

ReviewContentUpdatePanel是它沒有被刪除或代碼添加更新面板&的名稱,它存在於aspx頁面並不會被刪除。有沒有人遇到過這個?

+0

你有沒有包含在頁面上有一個ScriptManager UserControl? – tvanfosson 2008-10-27 02:31:35

+0

是的,和usercontrol上的scriptproxy – 2008-10-27 02:32:41

+1

你可以發佈代碼嗎?大多數對這個錯誤的引用處理動態添加updatepanels/controls。用戶控件是否動態添加? – tvanfosson 2008-10-27 03:06:42

回答

4

你是否在移動代碼控制?如果是這樣看看here,看看這是否能解決您的問題。

1

在您的標記中,確保您已爲其父級層次結構中的UpdatePanels和每個runat =「server」控件指定了一個ID。

5

當使用Clear method清除UpdatePanel所在的Controls集合時,或者使用Remove method刪除特定的UpdatePanel時,會發生此錯誤。

這些方法的觸發器可以是包含UpdatePanel的控件的執行CreateChildControls method。通常,如果此方法被重複調用,則在此方法的頂部調用Controls.Clear(),以啓動乾淨的平臺。

3

我以前曾經發生過這種情況。爲了解決它,我剛刪除它,然後重新創建它,問題就消失了。

0

您是否嘗試過在用戶控件中包含ScriptManagerProxy?

0

嘗試刪除UserControl的scriptproxy。在這種情況下,您的頁面上只有一個ScriptManager。

0

這是一個很長的一段時間,但我有AJAX擴展的經驗,特別是更新面板,其中由子控件拋出的錯誤表現爲由更新面板拋出的不同錯誤。我沒有看到這個特定錯誤的引用拋出由於錯誤的子控件:

http://msmvps.com/blogs/shareblog/archive/2009/03/11/cannot-unregister-updatepanel-with-id-since-it-was-not-registered-with-the-scriptmanager-and-moss.aspx

不知道這是否是你或不是這樣的,但我花了很多時間追了下去由於這個錯誤的錯誤。

2

我希望這可以幫助別人,因爲它驅使我堅果。在這裏和其他地方發現了各種各樣的信息後,我終於提出了以下修復方案。請注意,我不是在這裏或其他地方動態創建此更新面板,並且大多數信息都與動態創建此控件有關,但我並不知道。

我在使用腳本管理器的母版頁繼承的頁面上使用Web用戶控件內的更新面板。我不知道這是組合是什麼造成了它,但是這是我的固定它(其中利用更新面板web用戶控件中):

protected override void OnInit(EventArgs e) 
{ 
    ScriptManager sm = ScriptManager.GetCurrent(this.Page); 
    MethodInfo m = (
    from methods in typeof(ScriptManager).GetMethods(
     BindingFlags.NonPublic | BindingFlags.Instance 
     ) 
    where methods.Name.Equals("System.Web.UI.IScriptManagerInternal.RegisterUpdatePanel") 
    select methods).First<MethodInfo>(); 

    m.Invoke(sm, new object[] { updatePanel }); 
    base.OnInit(e); 
} 
相關問題