0

Hi I've an input button like

<input id="btnDelete" type="button" value="Delete" name="btnDelete" runat="server" onclick="return confirm('Are you sure you wish to delete these records?');" />

and my serverside code is

Private Sub btnDelete_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDelete.ServerClick

' my code here

End Sub

but when I click on delete button I'm getting confirm msg box, but after that it is not going to server side event.

Anything wrong in this?

Thank you

jestges
  • 3,686
  • 24
  • 59
  • 95

2 Answers2

1

USE OnClientClick for your client side javascript validation

   <asp:BUTTON id="btnDelete"  name="btnDelete" value="Delete" onclick="btnDelete_ServerClick"                    
    OnClientClick="return confirm('Are you sure you wish to delete these records?');"/>

IF you are using HTML control then this may be helpful: How to call code behind server method from a client side javascript function?

CHECK THIS OUT ALSO _doPostBack()

Community
  • 1
  • 1
Pranav
  • 8,563
  • 4
  • 26
  • 42
0

Maybe because its not a type=submit button?

<form name="frmPerson" action="/dome.asp">
   some form fields here
   .
   .
   <input id="btnDelete" type="submit" name="btnDelete" value="Delete" />
</form>
Kerry Kobashi
  • 806
  • 6
  • 9
  • Hi thank you for your quick reply. It is working fine but, I've another textbox in the page with server event. For all these events btnDelete_ServerClick this method is getting fired. How to control this? I want to fire this event when ever I click on btnDelete button only. btnDelete_ServerClick this method is getting fired because default focus is going to this button automatically – jestges Feb 14 '12 at 05:56