OnClick不与OnClientClick一起开火

时间:2016-05-17 19:08:04

标签: c# asp.net

我有以下代码。我需要有一个确认,然后在服务器上删除..如果我有OnClick它不会触发。任何的想法?

 <asp:Button ID="btnDelete" runat="server" Text="Delete Report"   OnClientClick="return confirm ('This will delete the report.  Continue?');" OnClick="btnDelete_Click" />


 protected void btnDelete_Click(object sender, EventArgs e)
 {
   // I have code here but it never fires

 }

1 个答案:

答案 0 :(得分:0)

添加&#34;返回false;&#34; OnClick之后。

 <asp:Button ID="btnDelete" runat="server" Text="Delete Report"   OnClientClick="return confirm ('This will delete the report.  Continue?'); return false; " OnClick="btnDelete_Click" />