2015-10-15 26 views
0

這裏註冊註銷UpdatePanel的是我的代碼:無法與ID 'UpdatePanel1',因爲它並沒有使用ScriptManager

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); 
} 

aspx文件:

<asp:UpdatePanel ID="UpdatePanel1" runat="server" 
OnUnload="UpdatePanel_Unload"></asp:UpdatePanel> 

現在,它顯示了錯誤:

'ASP.v4_inbox_new_aspx' does not contain a definition for 'UpdatePanel_Unload' and no extension method 'UpdatePanel_Unload' accepting a first argument of type 'ASP.v4_inbox_new_aspx' could be found (are you missing a using directive or an assembly reference?)

The name 'updatePanel' does not exist in the current context

+0

我認爲它告訴你UpdatePanel_Unload函數不存在於代碼後面的文件中。 –

+0

其中?,它的完整源代碼,它被放置在主文件中:asp:ScriptManager ID =「ScriptManager1」runat =「server」> pcs

回答

0

'ASP.v4_inbox_new_aspx' does not contain a definition for 'UpdatePanel_Unload' and no extension method 'UpdatePanel_Unload' accepting a first argument of type 'ASP.v4_inbox_new_aspx' could be found (are you missing a using directive or an assembly reference?)

這是您marku的結果電話號碼:

<asp:UpdatePanel ID="UpdatePanel1" runat="server" OnUnload="UpdatePanel_Unload"></asp:UpdatePanel> 

特別是OnUnload="UpdatePanel_Unload"是因爲UpdatePanel_Unload錯在你的代碼不存在。

The name 'updatePanel' does not exist in the current context E:\selva\19-09-2015\AlertID4\UI\V4\Inbox_new.aspx.cs

這是你的代碼的結果:

m.Invoke(sm, new object[] { updatePanel}); 

updatePanel不被任何定義。

+0

因此,我應該怎麼做, c#..幫我,請 – pcs

+0

我的主要錯誤是,無法取消註冊帶UpdatePanel1的UpdatePanel,因爲它沒有在ScriptManager中註冊。因爲只有我添加了上面的代碼。 – pcs

+0

我真的不明白那個評論。我不知道在這種情況下取​​消註冊是什麼意思。我的回答解釋了你的錯誤信息 - 我的解釋對你是否清楚? – Amit

相關問題