Our apps are required to "monitor" changes that a user makes to a form. For example, if a user changes the value of a dropdown box and tries to navigate away from the page, the app will warn the user -- using a Javascript dialog box -- that any unsaved changes will be lost if he navigates away from the page, unless he clicks the cancel button that appears on the Javascript dialog box. My questions is: Is there an easy way to monitor changes made to a Web Date Chooser object? Currently, I am using an <asp:textbox> control to monitor changes. Its value is set to an empty string, and its value changes when the user selects/clears a date value (this is handled in the web date chooser's _ValueChanged method). When that textbox value changes, the app will warn the user about losing unsaved changes if he tries to navigate away from the page. While this approach works fine, I'd prefer to monitor changes without the addition of a textbox control. Has anyone succeeded in doing so?
WebDateChoosers have the following Client-Side events: TextChanged and ValueChanged. You can set the variables there.
The events are pretty easy to implement in Visual Studio. In the properties window, expand the ClientSideEvents property and you'll see all the Javascript events you can implement. Click the empty cell next to the event you want to implement. You should see the words "Add new handler..." After you click it, you can click OK in the prompt that comes up, or enter your own function name and then click OK. VS will automatically embed the function prototype in your ASPX, and you can implement your own Javascript code there.
HTH
Craig
I am also implementing logic to warn a user about navigating away from a web page if they have made changes. I'm using a lot of JavaScript for this. When the user makes a change, I set a variable "hasChanged" equal to True. This way the user is only warned if they have actually made a change. I do this in the onClick event for checkboxes and radiobuttons, the onChange event for dropdownlists, and the onKeyDown event for textboxes. I cannot seem to find the javascript event which is triggered when the user selects a new date in the webdatechooser or the webcalendar (I need to track changes to both).
Any thoughts?
If you've got this notification working with a textbox, you're most of the way there.
You can declare a JavaScript variable in the head of your page, after which you can manipulate or check the value of that variable in the same way you're currently using the textbox.