gpt4 book ai didi

c# - Gridview ItemTemplate 中的 updatePanel 在回发时有问题

转载 作者:太空宇宙 更新时间:2023-11-03 10:50:29 24 4
gpt4 key购买 nike

在我的 gridItemTemplate 中,我有更新面板和复选框,

<ItemTemplate>
<asp:UpdatePanel runat="server" ID="upChkOption">
<ContentTemplate>
<asp:CheckBox runat="server" ID="chkOption" AutoPostBack="true"
OnCheckedChanged="chkOption_CheckChanged">
</ContentTemplate>
</asp:UpdatePanel>
</ItemTemplate>

第一次运行没有错误,但是在postback之后,出现了这个错误

Cannot unregister UpdatePanel with ID 'upChkOption' 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

我该如何解决?

最佳答案

UpdatePanel_Unload 添加到 UpdatePanelOnUnload 事件中:

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

在后面的代码中添加

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

Adding/removing UpdatePanels dynamicaly from a page

cannot-unregister-updatepanel-since-it-was-not-registered-with-the-scriptmanager-error

关于c# - Gridview ItemTemplate 中的 updatePanel 在回发时有问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21594761/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com