tags:

views:

31

answers:

2

I am working on an WebForms app, and we want to put a speed bump, for lack of a better term, in for the users at a particular point in the app. There is a particular action which is not supposed to be undone. So when they click the button to do that action we want to display a small confirmation window, have them enter a random string that we give them. Once they enter that string, and it matches the corresponding label, the submit button becomes enablesand they can perform the action. But for the life of me I can't figure out a good way to do this client side with WebForms. Is there a simple mechanism to use this type of workflow without a ton of post back events?

Note: This is an internal app where high security isn't truly a necessary requirement in this case. As I said, this is meant to be something to slow the user down slightly.

A: 

You could generate the javascript method to check the code (including the code in the method) server side and use registerclientscriptblock (or whatever the current method is), then use the onblur to call that method.

David
+1  A: 

This is similar to the mint.com confimration style.

Add JavaScript to the textbox onChange or onKeyUp event, there do your check and enable the button.

For example:

<script type="text/javascript">
function checkConfirmationText(){
 // Check if value of entered text = value of hidden text
 var isOk = document.getElementById('confirmation-label').value == document.getElementById('confirmation-text').value);

 // Show/Hide button depending on the text
 document.getElementById('btn-submit').style.dispaly = isOk ? '' : 'none';
}
</script>

<!--  HTML  -->
<input type="hidden" id="confirmation-label" value="DELETE" />
Enter "DELETE": <input type="text" id="confirmation-text" value="" onkeyup="checkConfirmationText()" />
<input type="submit" id="btn-submit" style="display:none" />
Alex
The idea is definitely right, made a few small changes for context and legibility of the javascript.
Matt