3

I have a asp.net panel that is initially hidden and is shown when a button is clicked. There is javascript inside that panel and it doesn't execute after the panel is set to be visible. I can see that javascript function gets outputted on page but it is not called. What can I do to make it so that function gets called? 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>
dev.e.loper
  • 35,446
  • 76
  • 161
  • 247

2 Answers2

1

You'll probably want to have some sort of end request method that gets called whenever an ajax method is called. this would have to be under the script resource.

<script type="text/javascript">

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

</script>
John Boker
  • 82,559
  • 17
  • 97
  • 130
0

Rather than doing that, why not use Page.ClientScript.RegisterStartupScript()l to trigger it to run.

Mitchel Sellers
  • 62,228
  • 14
  • 110
  • 173