Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing INamingContainer Interface for UpdatePanel?

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?

like image 521
LoganFrederick Avatar asked Jul 23 '09 19:07

LoganFrederick


1 Answers

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

like image 194
Rex M Avatar answered Oct 10 '22 16:10

Rex M