views:

1204

answers:

1

Even in trying to find an answer to this problem, I haven't found any clear explanation (especially one not discussing GridViews) on how to resolve the following error I receive when running a program with an UpdatePanel:

Message: Control with ID 'lblDisplay' being registered through RegisterAsyncPostBackControl or RegisterPostBackControl must implement either INamingContainer, IPostBackDataHandler, or IPostBackEventHandler.

The UpdatePanel is:

<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>

From my understanding, I have to implement the INamingContainer interface for lblDisplay, but am not quite sure on how to accomplish this. Do I have to databind the UpdatePanel information? Create a new object for INamingContainer?

+1  A: 

The problem is that Label does not fire a postback event - it is not interactive. For something to be registered as a PostBackTrigger, it must somehow fire a Postback command - usually in response to some user input - which the UpdatePanel can then intercept. Or the control registered as the trigger must be able to contain controls which fire postback events - e.g. an INamingContainer (for example a Panel).

Rex M
My UpdatePanel isn't supposed to receive any user input. The only action takes place in lblDisplay2, with its ontick event. The panel should simply refresh after events on the server with new information. If lblDisplay isn't posting anything back, what's an alternative to accomplish this?
LoganFrederick
@Logan the Label control does not have an OnTick event... are you trying to use a Timer control? If so, that control should be your PostBackTrigger, not the label. Labels do not fire postback events - that is a client-side event. Labels are only written to from the server.
Rex M
Yes, I'm trying to use a Timer control, and understand the events on the server-side in C#, but don't quite understand how it interacts and is initiated on the client-side in ASP. This is probably leading to a separate question than the original one.
LoganFrederick
I may have identified my problem, haven't tested yet, but would:<asp:Timer Interval="5000" OnTick="tick"></asp:Timer>Accomplish what I was trying to do through that label? I'll update in a couple minutes if it succeeds or not.
LoganFrederick