Every postback causes page_load to fire. Put code in your page load to
determine whether or not the action should be allowed. If it's not a
postback, you can easily handle it thru scripting or validation.
--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"Stanley" <webmaster@nospam-glass-images.com> wrote in message
news:%23Fad%23ntAEHA.4080@TK2MSFTNGP09.phx.gbl...[color=blue]
> Actually no Alvin a Validator wont work for what I need. If the user[/color]
clicks[color=blue]
> a link to go to another page that is listed on my menu a validator won't
> stop them from going. That was the request made by my boss.
>
> -Stanley
>
> "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
> news:uPmL68kAEHA.2480@TK2MSFTNGP11.phx.gbl...[color=green]
> > What i think you need, if i understand you correctly, is a validation
> > control in there. The role of a validation control is to make sure that[/color]
> the[color=green]
> > user has entered input before they move on. Have a look at the visual[/color]
> studio[color=green]
> > toolbox for the appropriate validation control
> >
> > --
> > Regards,
> > Alvin Bruney [ASP.NET MVP]
> > Got tidbits? Get it here...
> >
http://tinyurl.com/3he3b
> > "Stanley" <webmaster@nospam-glass-images.com> wrote in message
> > news:%23so6tSeAEHA.3220@TK2MSFTNGP10.phx.gbl...[color=darkred]
> > > No I have not resolved this issue yet.
> > >
> > > -Stanley
> > >
> > > "Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
> > > news:%23WlnPaZAEHA.2316@TK2MSFTNGP10.phx.gbl...
> > > > Your post went unanswered. Have you resolved this issue?
> > > >
> > > > --
> > > > Regards,
> > > > Alvin Bruney [ASP.NET MVP]
> > > > Got tidbits? Get it here...
> > > >
http://tinyurl.com/3he3b
> > > > "Stanley" <webmaster@nospam-glass-images.com> wrote in message
> > > > news:eHB%23i5IAEHA.2040@TK2MSFTNGP12.phx.gbl...
> > > > > Hello all,
> > > > > I have a need to make sure that no users leave a form without[/color][/color][/color]
being[color=blue][color=green][color=darkred]
> > > warned
> > > > > that they have un-saved data. I have the script below that I found[/color][/color]
> on[color=green][color=darkred]
> > > > > egghead.com but there is an issue with it that if I have a[/color][/color][/color]
dropdown[color=blue][color=green]
> > that[color=darkred]
> > > > > posts back so that I can show another field if the user chooses[/color][/color]
> other[color=green][color=darkred]
> > > then
> > > > > the warning pops up. If I use an attribute on the dropdown to use[/color][/color]
> the[color=green][color=darkred]
> > > > > OnChange event and set the bSubmitted=True that takes care of the[/color][/color]
> post[color=green][color=darkred]
> > > > back
> > > > > issue but causes another issue. The other issue is now the user[/color][/color][/color]
can[color=blue][color=green][color=darkred]
> > > leave
> > > > > the form without any warning. So what I am looking for is a better[/color][/color]
> way[color=green][color=darkred]
> > > to
> > > > be
> > > > > able to handle form post backs and still give the user the[/color][/color][/color]
warning.[color=blue][color=green]
> > Has[color=darkred]
> > > > > anyone done this before?
> > > > >
> > > > > TIA
> > > > >
> > > > > -Stanley
> > > > >
> > > > > [script]
> > > > > var bSubmitted=false;
> > > > >
> > > > > function isDirty(oForm)
> > > > >
> > > > > {
> > > > >
> > > > > if(bSubmitted)
> > > > >
> > > > > {
> > > > >
> > > > > return false;
> > > > >
> > > > > }
> > > > >
> > > > > var iNumElems = oForm.elements.length;
> > > > >
> > > > > for (var i=0;i<iNumElems;i++)
> > > > >
> > > > > {
> > > > >
> > > > > var oElem = oForm.elements[i];
> > > > >
> > > > > if ("text" == oElem.type || "TEXTAREA" == oElem.tagName)
> > > > >
> > > > > {
> > > > >
> > > > > if (oElem.value != oElem.defaultValue)
> > > > >
> > > > > {
> > > > >
> > > > > return true;
> > > > >
> > > > > }
> > > > >
> > > > > }
> > > > >
> > > > > else if ("checkbox" == oElem.type || "radio" == oElem.type)
> > > > >
> > > > > {
> > > > >
> > > > > if (oElem.checked != oElem.defaultChecked)
> > > > >
> > > > > {
> > > > >
> > > > > return true;
> > > > >
> > > > > }
> > > > >
> > > > > }
> > > > >
> > > > > else if ("SELECT" == oElem.tagName)
> > > > >
> > > > > {
> > > > >
> > > > > var oOptions = oElem.options;
> > > > >
> > > > > var iNumOpts = oOptions.length;
> > > > >
> > > > > for (var j=0;j<iNumOpts;j++)
> > > > >
> > > > > {
> > > > >
> > > > > var oOpt = oOptions[j];
> > > > >
> > > > > if (oOpt.selected != oOpt.defaultSelected)
> > > > >
> > > > > {
> > > > >
> > > > > return true;
> > > > >
> > > > > }
> > > > >
> > > > > }
> > > > >
> > > > > }
> > > > >
> > > > > }
> > > > >
> > > > > return false;
> > > > >
> > > > > }
> > > > >
> > > > > function checkFormStatus(){
> > > > >
> > > > > var frm = document.forms[0];
> > > > >
> > > > > if(isDirty(frm))
> > > > >
> > > > > event.returnValue = "You have entered form Data, or Data has been
> > > entered
> > > > > for you, without submitting this form.";
> > > > >
> > > > > }
> > > > >
> > > > > if ( typeof( window.addEventListener ) != "undefined" ) {
> > > > >
> > > > > window.addEventListener("onbeforeunload", checkFormStatus, false);
> > > > >
> > > > > } else if ( typeof( window.attachEvent ) != "undefined" ) {
> > > > >
> > > > > window.attachEvent("onbeforeunload", checkFormStatus);
> > > > >
> > > > > }
> > > > >
> > > > > [/script]
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color]