ASP.NET: Warning on changed data closing windows

后端 未结 6 1519
深忆病人
深忆病人 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 22:48

    On the Page_Unload event (or call this function in your body tag, ), you can have a check if the form has data in it. Then you could run some Java:

    
    

    See how that works out for ya

    EDIT: It may not prevent the closing of the window, but it will alert your user that they have unsaved data in your form.

    Confirmed does NOT work cross-browser, I will investigate a different method and post it up here.

提交回复
热议问题