Thursday, 17 July 2014

Stop partial Postback of Form using Javascript



javaScript to stop partial postback of form.


    $(document).ready(function () {
            $("form").submit(function (e) {
                var prm = Sys.WebForms.PageRequestManager.getInstance();
                var v = prm.get_isInAsyncPostBack()
                if ($("#txt").val() == "1") {
                    prm.abortPostBack();
                }
            })
     })


HTML :

       <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <input type="text" id="txt" />
                <asp:Button ID="btn" runat="server" CssClass="temp" Text="Click" />
            </ContentTemplate>

        </asp:UpdatePanel>

No comments:

Post a comment