Wednesday, 17 April 2019

Call JavaScript function after AJAX UpdatePanel Refresh (Partial PostBack) in ASP.Net

<asp:UpdatePanel runat="server">
<ContentTemplate>
Employee :
    <asp:ListBox ID="lstEmployee" runat="server" SelectionMode="Multiple">
        <asp:ListItem Text="Nikunj Satasiya" Value="1" />
        <asp:ListItem Text="Dev Karathiya" Value="2" />
        <asp:ListItem Text="Hiren Dobariya" Value="3" />
        <asp:ListItem Text="Vivek Ghadiya" Value="4" />
        <asp:ListItem Text="Pratik Pansuriya" Value="5" />
    </asp:ListBox>
</ContentTemplate>
</asp:UpdatePanel>


<script type="text/javascript">
    window.onload = function () {
        DrawEmployeeDDL();
    };

    //On UpdatePanel Refresh
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    if (prm != null) {
        prm.add_endRequest(function (sender, e) {
            if (sender._postBackSettings.panelsToUpdate != null) {
                DrawEmployeeDDL();
            }
        });
    };

    function DrawEmployeeDDL() {
        $('[id*=lstEmployee]').multiselect({
            includeSelectAllOption: true
        });
    };
</script>


No comments:

SQL: Generate a range of numbers

SELECT ones.n + 10*tens.n + 100*hundreds.n + 1000*thousands.n FROM       (VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) ones(n),      (VALU...