這裏註冊註銷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
我認爲它告訴你UpdatePanel_Unload函數不存在於代碼後面的文件中。 –
其中?,它的完整源代碼,它被放置在主文件中:asp:ScriptManager ID =「ScriptManager1」runat =「server」> asp:ScriptManager> – pcs