保留更改,同时保留页面asp net [英] prompt save changes while leaving page asp net

查看:61
本文介绍了保留更改,同时保留页面asp net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



目前我的页面有不同的标签。虽然我正在尝试从一个标签切换到另一个标签,但有任何修改。 promt保存并离开页面。但是在其中一个页面中。我点击链接按钮时文本框的文本框和链接按钮值被更改(单击弹出窗口打开,我们必须选择值)。在这种情况下promt merssage没有显示。



任何帮助\评价都非常感谢。



谢谢提前,

Balu

解决方案

您需要使用一些客户端脚本,在onbeforeunload事件期间执行此检查。

  var  showPrompt =  true ; 
var isModified = false ;
var hidePopup = false ;

function onBeforeUnload(){
if (showPrompt){
if (isModified){
if (hidePopup || confirm( 单击确定保存更改,或单击取消放弃更改。)){
doSave ();
}
}
}
showPrompt = true ;
hidePopup = false ;
}



- 当你点击一个不会导航你离开页面的锚标记时,showPrompt可以设置为false。例如

< a onclick =showPrompt = falsehref =javascript:doX()/> 



- isModified可以使用跟踪何时需要保存的东西。例如,您可以执行

 


(input)。onchange(function(){isModified = true;});

要跟踪撤消,你可能想用一个函数替换isModified,该函数检查上次保存状态的当前状态。



- hidePopup让我们强制保存而不确认用户


Hi All,

Currently i'm having page with different tabs.While i'm trying switch from one tab to another with any modifications.there is a promt to save and leave the page.But in one of the page.I have textbox and link button value of the text box is changed while clicking on link button(In click popup is opened and we have to select value).In this case the promt merssage is not showing.

Any help\Comments are highly appreciated.

Thanks in advance,
Balu

解决方案

You'll need using some client side scripting which does this check during the onbeforeunload event.

var showPrompt=true;
var isModified=false;
var hidePopup=false;

    function onBeforeUnload() {
        if (showPrompt) {
            if (isModified) {
                if (hidePopup || confirm("Click ok to save your changes or click cancel to discard your changes.")) {
                    doSave();
                }
            }
        }
        showPrompt = true;
        hidePopup = false;
    }


- showPrompt can be set to false when your clicking on an anchor tag which won't navigate you away from the page. For example

<a onclick="showPrompt=false" href="javascript:doX()" />


- isModified can be used to track when you need to save something. You could for example do something like


("input").onchange(function(){isModified=true;});

To track undo's you might want to replace isModified with a function which checks the current state from the last saved state.

- hidePopup lets us force a save without confirming to the user.


这篇关于保留更改,同时保留页面asp net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆