Cancelling postback with JavaScript

  • Thread starter Thread starter Steve Peterson
  • Start date Start date
S

Steve Peterson

Hi

I have a asp button on a page. This button, on it's btnDelete_Click() event
in the code behind will delete a record from the db. What I would like to do
is put in some sort of JavaScript that will present a "Confirm" message box.
If the user presses cancel, then nothing happens, or rather the form is not
posted back to the server thus causing the btnDelete_Click event to fire.

I'm having the hardest time figuring out how to do this. JavaScript is not
my forte to begin with, plus mixing it with ASP.Net makes it even more
tricky to work with..

Can someone help me out please?

TIA

Steve
 
Hey Steve

Hope this will hel

1- Place a server side control on the form or simple button the web for
2- Write java script function like under in HTML Code for your web for

<script lang="javascript"
function ConfirmPostBack(

if (confirm('Do you want to Delete Data ?')==true
return true
els
return false

</script

3 - On Page load event of web form add attribute for the button as unde

myBtn.attributes.add("onClick","return ConfirmPostBack();"

4- Write code for your delete function in button's handle
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top