473,320 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

PageDirty

Dear All

I have a page which has different editable usercontrols on it. All of these controls let user proivide data. My page has several usercontrols that are editable. In the edit mode, when the user changes state on the control, that page is set to dirty.The user try to navigate with out save,i need the the message the page is dirty.I am having the infragistics controls in my page.
how to do this.


Thanks
Anitha
Nov 20 '09 #1
1 1555
Frinavale
9,735 Expert Mod 8TB
You will have to use JavaScript to do this.

The OnBeforeUnload Event is a neat feature used by web developers to let the user cancel the page submit if they need to.

What you'll have to do is add a HiddenField to the page indicating whether or not the page is dirty.

Write a JavaScript function that will handle the OnBeforeUnload JavaScript event. This function will check the HiddenField, and if the page is dirty will return "You have unsaved changes. Are you sure you want to leave the page?".

The only thing is that this event will fire every time the page is unloaded.
So you'll also need to write a bit of JavaScript that determines whether or not to display the message depending on if the page is posting back for reasons other than leaving current page.


Note: that the onbeforeunload event happens when the whole page is being unloaded....this means that if you're using Ajax this event will not fire.

If you just want to check if the page is dirty when the user clicks on some control that leads the user away from your page then you could just call the function that checks if the page is dirty during the OnClick (or onChange) event (client side) for the control.

If you want to inform the user that they will lose information if they are leaving the page by hitting the back button, or typing a new url ...etc...then use the OnBeforeUnload event.

-Frinny
Nov 20 '09 #2

Sign in to post your reply or Sign up for a free account.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.