ASP.NET: Warning on changed data closing windows

后端 未结 6 1477
深忆病人
深忆病人 2021-01-06 22:26

I\'d like to warn users when they try to close a browser window if they didn\'t save the changes they made in the web form.

I\'m us

6条回答
  •  迷失自我
    2021-01-06 23:00

    You could create a control that extends IExtenderProvider and have that create the JavaScript to track the changes (or more likely register the controls with a change tracking mechanism).

    You're still going to have to implement the change tracking in Javascript though, unless you want a lot of Postbacks.

    I did this at a previous employer using Prototype.Js. I think the only difficult thing was the difference between the way that Internet Explorer and Firefox require the "cancel navigation" flag to be set.

提交回复
热议问题