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
谢谢
2 个解决方案
#1
1
USE OnClientClick for your client side javascript validation
使用OnClientClick进行客户端javascript验证
<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?
如果您正在使用HTML控件,那么这可能会有所帮助:如何从客户端javascript函数调用服务器方法后面的代码?
CHECK THIS OUT ALSO _doPostBack()
检查这个也是_doPostBack()
#2
0
Maybe because its not a type=submit button?
也许是因为它不是一个type = submit按钮?
<form name="frmPerson" action="/dome.asp">
some form fields here
.
.
<input id="btnDelete" type="submit" name="btnDelete" value="Delete" />
</form>
#1
1
USE OnClientClick for your client side javascript validation
使用OnClientClick进行客户端javascript验证
<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?
如果您正在使用HTML控件,那么这可能会有所帮助:如何从客户端javascript函数调用服务器方法后面的代码?
CHECK THIS OUT ALSO _doPostBack()
检查这个也是_doPostBack()
#2
0
Maybe because its not a type=submit button?
也许是因为它不是一个type = submit按钮?
<form name="frmPerson" action="/dome.asp">
some form fields here
.
.
<input id="btnDelete" type="submit" name="btnDelete" value="Delete" />
</form>