嗨,我有一个像
这样的输入按钮<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
但是当我点击删除按钮时,我收到确认信息框,但之后它不会进入服务器端事件。
这有什么不对吗?
谢谢
答案 0 :(得分:1)
USE 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?');"/>
如果您使用的是HTML控件,那么这可能会有所帮助:How to call code behind server method from a client side javascript function?
还要检查_doPostBack()
答案 1 :(得分:0)
也许是因为它不是type = submit按钮?
<form name="frmPerson" action="/dome.asp">
some form fields here
.
.
<input id="btnDelete" type="submit" name="btnDelete" value="Delete" />
</form>