即使在试图找到这个问题的答案时,我也没有找到任何明确的解释(特别是没有讨论GridViews)如何解决我在运行带有UpdatePanel的程序时收到的以下错误:
Message: Control with ID 'lblDisplay' being registered through RegisterAsyncPostBackControl or RegisterPostBackControl must implement either INamingContainer, IPostBackDataHandler, or IPostBackEventHandler.
UpdatePanel是:
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"></asp:ScriptManager>
<asp:UpdatePanel ID="up1" UpdateMode="Conditional" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lblDisplay" eventname="Load" />
</Triggers>
<ContentTemplate>
<asp:HiddenField ID="hiddenZone" runat="server" />
<asp:HiddenField ID="hiddenZone2" runat="server" />
<div style='width: 150px;position:absolute; margin-left: 0;text-align:center;'>
<span id="clock" style='font-size:125%;'></span>
<asp:Label ID="lblDisplay" runat="server" Text=""></asp:Label></div>
<div style='width:150px;position:absolute;margin-left:150px;text-align:center;text-transform:capitalize;'>
<asp:Label ID="lblDisplay2" runat="server" Text="" Interval="5000" ontick="tick"></asp:Label>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</form>
根据我的理解,我必须为lblDisplay实现INamingContainer接口,但我不太清楚如何实现这一点。我是否需要数据绑定UpdatePanel信息?为INamingContainer创建一个新对象?