Search code examples
c#asp.netwebformsupdatepanel

text is not allowed between the opening and closing tags update panel


Why am not sure, why I am receiving this warning or error for my update panel,

text is not allowed between the opening and closing tags update panel

Here;s markup

<script type="text/javascript">
    function bringPOPup() 
    {     
        $.blockUI({message: $('#anotherUP'), css: { width: '600px' } });
    }
</script>



<div id="anotherUP" style="display: none; cursor: default">
    <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
        <ContentTemplate>
                <asp:DropDownList ID="drop1" runat="server" EnableViewState="true" AutoPostBack="true" OnSelectedIndexChanged="Drop1_SelectedIndexChanged"/>
        </ContentTemplate>
     <Triggers>
        <asp:AsyncPostbackTrigger ControlID="drop1" EventName="SelectedIndexChanged" />
    </Triggers>
    </asp:UpdatePanel>
</div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
    <ContentTemplate>
        <input type="button" id="Button3" value="Click me to Bring Pop Up" onclick="bringPOPup()" />
        <br />
    </ContentTemplate>
</asp:UpdatePanel>

Can someone tell me whats wrong as I googled it and nothing is coming up as wrong.


Solution

  • What this error is indicating is that you can't have plain text directly inside an UpdatePanel - the only things that can be an immediate child of the UpdatePanel are <Triggers> and <ContentTemplate>.

    Here's an example of what's not allowed:

    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
        You can't put text right here, this will cause an error!
        <ContentTemplate>
            <input type="button" id="Button3" value="Click me to Bring Pop Up" onclick="bringPOPup()" />
            <br />
        </ContentTemplate>
    </asp:UpdatePanel>
    

    The text I added outside the ContentTemplate will cause that error.

    I don't see anything in the code you've shown so far that would cause the error, but that is what you need to look for. It's probably somewhere in code elsewhere on the page.