Hey,
first of all, sorry for my bad English. I hope you can understand, what I need ;)
I have a ASP.NET Application with one page, where users can setup filter settings. I want to have such a message as described here, but it doesn't work correctly.
If I add "IGNORE_UNLOAD = true" to the 'textChanged'- or 'checkedchanged'-Event I get the error, that thats not found. So I tried a work-around and did it in the vb-part. I have a invisible checkbox in my contentplaceHolder which is checked, when a setting has changed and unchecked at startup or after saving changes with the buttons. But the problem is, that the javascript-code is executed before the vb-events are...started(?).
I really need your help.
I am using Visual Studio 2005 and IE 7. My application has a masterpage which contains a Form. In my page "filter.aspx" is a ContentPlaceHolder, which contains my controls.
Here is my code:
<%@ Page Language="vb" Debug="true" MasterPageFile="MasterPage.master" AutoEventWireup="false" validateRequest="false" Inherits="Projecttasks.filter" Codebehind="filter.aspx.vb" %>
<asp:Content ID="contentOR" runat="server" ContentPlaceHolderID="cphInhaltOR">
<script type="text/javascript">
var UNLOAD_MSG = "Ungespeicherte Daten gehen verloren!";
var IGNORE_UNLOAD = true;
function doBeforeUnload() {
var vChange = document.getElementById("ctl00_cphInhaltOR_cbChange").checked;
var strIsPostBack = theForm.__EVENTTARGET.value;
var Ergebnis = strIsPostBack.search(/.+bSenden.+/);
if (strIsPostBack.length == 0 || Ergebnis == -1) {
if (vChange) {
if(window.event)
window.event.returnValue = UNLOAD_MSG;
else
return UNLOAD_MSG;
};
};
};
if(window.body1)
window.body1.onbeforeunload = doBeforeUnload;
else
window.onbeforeunload = doBeforeUnload;
</script>
<h1 class="anmeldung">
<asp:Label ID="lFilterH" runat="server" Text="Konfiguration des persönlichen Filters"></asp:Label>
<asp:Label ID="lVerantw" runat="server" Text="Name"></asp:Label></h1>
...a lot of tables, asp:Labels, asp:Checkboxes, asp:Textboxes... if you want I can post it
</asp:Content>
And the importants part of my VB-Code
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
cbChange.Checked = False
...
End Sub
Protected Sub bSpeichern_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bSpeichern.Click
cbChange.Checked = False
....
End Sub
Protected Sub cbAll_CheckedChanged(ByVal sender As Object, ByVal e As EventArgs) Handles cbAS400Nr.CheckedChanged, _
cbAusfKostSt.CheckedChanged, cbBearbArt.CheckedChanged, cbBelKostSt.CheckedChanged, _
cbDauer.CheckedChanged, cbEigNotiz.CheckedChanged, cbIdentNo.CheckedChanged, cbInfo.CheckedChanged, _
cbKostMKb.CheckedChanged, cbKostOKb.CheckedChanged, cbKunde.CheckedChanged, cbNotiz.CheckedChanged, _
cbProjBeschr.CheckedChanged, cbProjLeiter.CheckedChanged, cbProjPlaner.CheckedChanged, cbProjQW.CheckedChanged, _
cbRessourcen.CheckedChanged, cbSpaltBreit.CheckedChanged, cbVertrAuftrNo.CheckedChanged, _
cbZeitraumBis.CheckedChanged, cbZeitraumVon.CheckedChanged
cbChange.Checked = True
End Sub
If it doesn't work this way, please try to give me another option, but I don't really want to use AJAX, because I have no idea how it works.
My error-description I get, when I try it like in the first post:
Compileerror: IGNORE_UNLOAD" is not a member of "ASP.Filter.aspx
Thank you for your help!!!