Javascript not executing after partial rendering

I have an asp.net panel that is initially hidden and appears when a button is clicked. There is javascript inside the panel, and it does not execute after the panel is configured for visibility. I see that the javascript function is being output to the page, but it is not being called. What can I do to call a function call? Here is an example:

<asp:LinkButton id="lbtn" runat="server" Text="show" OnClick="lbtn_Click" />
    <asp:UpdatePanel id="upnl" runat="server" UpdateMode="Conditional">
       <contenttemplate>
        <asp:panel id="pnlContent" runat="server" visible="false">
            content initially hidden.

            <script>
                alert('done!');
            </script>
        </asp:panel>
    </contenttemplate>
    <triggers>
        <asp:AsyncPostBackTrigger ControlID="lbtn"/>
    </triggers>
</asp:UpdatePanel>
+3
source share
2 answers

You will probably need some kind of final request method that is called whenever the ajax method is called. this should be under the script resource.

<script type="text/javascript">

    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_endRequest(function(sender, args){ alert("endRequest"); });

</script>
+1
source

Page.ClientScript.RegisterStartupScript() l, .

0

Source: https://habr.com/ru/post/1775048/


All Articles