Total Pageviews

Tuesday, 7 July 2015

Rebind JQuery/Javascript Events in ASP.NET UpdatePanel's Async postback





<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            loadData();

        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" AsyncPostBackTimeout="0" runat="server"></asp:ScriptManager>
        <script type="text/javascript">
            //On UpdatePanel Refresh
            var prm = Sys.WebForms.PageRequestManager.getInstance();
            if (prm != null) {
                prm.add_endRequest(function (sender, e) {
                    if (sender._postBackSettings.panelsToUpdate != null) {
                        loadData();
                    }
                });
            };
        </script>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                /* Postback Controls here*/
            </ContentTemplate>
        </asp:UpdatePanel>
    </form>
</body>
</html>

No comments:

Post a Comment