Hi all
I have a list of countries that can be mapped to a particular user. The list is build up dynamically through a database query parsed through XSLT - so all the list controls are created dynamically. Any country that is mapped to the user is checked by default.
I want a confirmation box to display if the number of countries checked is less than the number that was originally allocated to the user in the database. I have the count in a hidden field and if the number of checkboxes checked is less than the count, I want to display a JavaScript confirmation box along the lines of "Are you sure you want to proceed?"
I got the code for this from one of the threads on the site so it's not my own brainpower here ;-)
I call the following code if this check count is, in fact, less:
page.RegisterClientScriptBlock("showConfirmation", "<SCRIPT FOR='window' EVENT='onload' LANGUAGE='JScript'>if (confirm('This action may potentially delete country mappings that were previously selected. This action cannot be undone and all associated region mappings will be deleted. Are you sure you wish to continue?'))" +
"{return true;}else{return false;};</SCRIPT>"
and it DOES show the confirmation box but no matter if I click OK or Cancel, the deletion still takes place?
What do I need to add/change to stop the execution of the deletion? I'm a bit reluctant to put an onclick event behind the button as I do all my processing in the CodeBehind page, and, as I said - all the controls are created dynamically.
Thanks as always
Craftor
I have a list of countries that can be mapped to a particular user. The list is build up dynamically through a database query parsed through XSLT - so all the list controls are created dynamically. Any country that is mapped to the user is checked by default.
I want a confirmation box to display if the number of countries checked is less than the number that was originally allocated to the user in the database. I have the count in a hidden field and if the number of checkboxes checked is less than the count, I want to display a JavaScript confirmation box along the lines of "Are you sure you want to proceed?"
I got the code for this from one of the threads on the site so it's not my own brainpower here ;-)
I call the following code if this check count is, in fact, less:
page.RegisterClientScriptBlock("showConfirmation", "<SCRIPT FOR='window' EVENT='onload' LANGUAGE='JScript'>if (confirm('This action may potentially delete country mappings that were previously selected. This action cannot be undone and all associated region mappings will be deleted. Are you sure you wish to continue?'))" +
"{return true;}else{return false;};</SCRIPT>"
and it DOES show the confirmation box but no matter if I click OK or Cancel, the deletion still takes place?
What do I need to add/change to stop the execution of the deletion? I'm a bit reluctant to put an onclick event behind the button as I do all my processing in the CodeBehind page, and, as I said - all the controls are created dynamically.
Thanks as always
Craftor