Search code examples
asp.netmodalpopupextender

Modal Popup Extender Saving Data Causes Page Refresh


I have a modal popup extender

  <asp:ModalPopupExtender ID="ModalPopupExtender1" TargetControlID="btnAddNewGuest"     BehaviorID="newGuestPopup"
        PopupControlID="pnlNewGuest" CancelControlID="btnGuestCancel"   BackgroundCssClass="modalBackground"
        DropShadow="false" runat="server">
    </asp:ModalPopupExtender>

pnlNewGuest contains all textboxes for input, a checkbox and btnSave. btnSave saves data to the server by calling the btnSave_Clicked at code behind.

On Checkbox onclick following jquery is called

    $("#<%=checkbox1.ClientID%>").click(function () {
        if ($("#<%=checkbox1.ClientID%>").is(':checked')) {
           $('#guestdiv1 :input').attr('disabled', true);
        }
        else {
            $('#guestdiv1 :input').attr('disabled', false);
       }
    });

Everything is working very smooth. The problem I face when I disable the controls in modal popup screen. The screen scrolls up however data is saved successfully.


Solution

  • It refreshes itself automatically since you probably didn't set the UpdatePanel's UpdateMode to Conditional - which means - each change you make to a control in the updatepanel will cause the updatepanel to be refreshed, and since you changed the "disabled" property - it refreshes itself