Quantcast
Channel: West Wind Message Board Messages
Viewing all articles
Browse latest Browse all 10393

Record Delete Confirmation

$
0
0
Record Delete Confirmation
Web Development with Visual FoxPro
Record Delete Confirmation
Apr. 2, 2013
06:18 am
3R31FFH0YShow this entire thread in new window
Gratar Image based on email address
From:Ray
To:Rick Strahl
Thanks for the reply Rick. Yes I am using a submit buttion as I need the foxpro event to fire so that I can delete the parent and any child records but only if the user confirms that they want to delete the record. The script I was trying to use is pretty simple and returns true or false based on the user response. Jquery does not seem to have anyway to get a user response. (of course I am new to this so there probably is a way)

What am I missing?

Ray

My code:

<code lang = "html">
<ww:wwWebButton ID="btnSubmitDelete" runat="server"
name="btnSubmitDelete"
onclientclick="ConfirmDelete"
Click="btnSubmitDelete_Material_Click" Text="Delete" />

<code lang = "javascript>

<script>
function ConfirmDelete() {
var r = confirm("Are you sure you want to Delete this Entry?");
if (r == true) {
return true;

}
else {
return false;
}
}
</script>


What are you attaching this to? A submit button? If you don't want the form to submit use a plain button not a submit button (ie. define it in client code).

Set UseSubmitButtonBehavior="false" to force a plain button to be created rather than a submit button.

<ww:wwWebButtonrunat="server"id="btnClient" UseSubmitBehavior="false" OnClientClick="doSomething()"Text="Client" />

If you need to shortcut submission of the form then you need:

OnClientClick="return doSomething()"

and return false from the OnClientClick().

In general it's better to not use these JavaScript event handlers on the control, but rather use JavaScript and jQuery to control this:

<script> $(document).ready( function() { $("#btnClient").click( function() { alert("DO Something!");returnfalse; }); });</script>

This will prevent the submit from submitting and you can skip the OnClientClick() logic altogether. Just make sure to add jQuery to the page.

+++ Rick ---


I have a java script that prompts for confirmation before a delete but the webbutton always does the click event. The doc's say returning a false from the script will prevent the click event but it always fires for me. The script pops up and returns either true or false.
From the doc's:
"If you use OnClientClick() on a submit button the button will still submit the form unless you return false from your JavaScript handler. "


Is there another way to make this work?


Thanks

Ray





Viewing all articles
Browse latest Browse all 10393

Trending Articles