Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
459
save changes on exiting the application
posted

how can i prevent the user to close the webapplication (x in internet explorer) without saving the changes in the ultrawebgrid?

elke

  • 508
    posted

    I got it. It can be done in the following way. The key is updating the readyState flag to false in AfterExitEditModeHandler.

    //////////////////////////

    var readyState = true;

    window.onbeforeunload = checkProgressState;


    function checkProgressState(){

    if (!readyState){

    message = "WARNING: Your data is not saved, if you choose to exit your information may be lost.";

    return message;

    }

    else

    {

    readyState = true;

    }

    }

     

    function HandleExitEditMode(gridID, cellID) {

    readyState = false;

    }

     ///////////////////

    If you want this alert to be suppressed in SaveButtonClick, then OnClientClick of that button, update the readyState variable to true.

  • 508
    posted

    Hey,

    I am also in the same situation. I need to prompt/save the grid data before exiting. Any clues on how to do it?

  • 100
    posted

     try it, but it only worked in IE:

    <html>
    <head>
    <body  onBeforeUnLoad="clean_exit(this)"  >
    something else........

    <script language="JavaScript">  
    var changes=false;
    var problems=false;
     
    function clean_exit( src ){
          verify();  
          if (problems){
                alert ("problems: " + problems);
                // the verify routine reports problems, don't allow an exit or reloading of the page
          }else{
                // no problems, so continue
                if(changes){        
                      if (!confirm("You have made changes.  Click OK to save, or cancel to continue without saving")){
                            return false;  
                      }else{
                            //do something  
                            return true;
                      }  // end of confirm
                } // end of changes
          }// end of verify
    }

    function changed(){    
          changes=true;
    }
     
    function verify(){    
          var problems=false;
          with (Entry) {
                if (LastName.value == "") {  
                      problems=true;
                      return false;
                }
          }
          changes=false;
          return true;
    }  
    </script>
    </body>
    </html>