“Cannot unregister UpdatePanel with ID 'xxx' since it was not registered with the ScriptManager… ” in RadGrid while editing record

血红的双手。 提交于 2019-11-29 01:50:16

I don't know why, but somehow the UpdatePanel is unregistered from the ScriptManger twice (it happens in RadGrid.Rebind() method too; the situation I was stuck in), and the second time it's unregistered from ScriptManger you get the "Cannot unregister UpdatePanel ..." error.

The workaround is to register the UpdatePanel with the ScriptManger somewhere between the two unregister events, using reflection, like this:

protected void UpdatePanel_Unload(object sender, EventArgs e) {
    MethodInfo methodInfo = typeof(ScriptManager).GetMethods(BindingFlags.NonPublic | BindingFlags.Instance)
        .Where(i => i.Name.Equals("System.Web.UI.IScriptManagerInternal.RegisterUpdatePanel")).First();
    methodInfo.Invoke(ScriptManager.GetCurrent(Page),
        new object[] { sender as UpdatePanel });
}

you should add the UpdatePanel_Unload to the OnUnload event of the UpdatePanel:

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

You can find the complete details of the problem here

Protected Sub UpdatePanel_Unload(ByVal sender As Object, ByVal e As EventArgs)
    Dim methodInfo As MethodInfo = GetType(ScriptManager).GetMethods(BindingFlags.NonPublic Or BindingFlags.Instance).Where(Function(i) i.Name.Equals("System.Web.UI.IScriptManagerInternal.RegisterUpdatePanel")).First()
    methodInfo.Invoke(ScriptManager.GetCurrent(Page), New Object() {TryCast(sender, UpdatePanel)})
End Sub


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

I had this issue as well.. when turning off pahing on the grid to to the export to EXCEL. I changed the rebind to be on the mastertableview

ie RadGrid1.MasterTableView.AllowPaging = false; RadGrid1.MasterTableView.Rebind();

instead of RadGrid1.MasterTableView.AllowPaging = false; RadGrid1.Rebind();

In case someone else had this...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!