admin管理员组文章数量:1426072
I'm currently coding a button which will delete a record from a database if clicked. However, I want some sort of confirmation after they click it so there are no accidents. I was imagining a popup box that tells them they are about to delete this record with two buttons cancel and OK. If cancelled, nothing happens, but if OK is pressed, then the server would execute the delete as coded. How would I do this in asp/vb?
I'm currently coding a button which will delete a record from a database if clicked. However, I want some sort of confirmation after they click it so there are no accidents. I was imagining a popup box that tells them they are about to delete this record with two buttons cancel and OK. If cancelled, nothing happens, but if OK is pressed, then the server would execute the delete as coded. How would I do this in asp/vb?
Share Improve this question edited Nov 22, 2009 at 21:14 Canavar 48.1k17 gold badges94 silver badges126 bronze badges asked Nov 22, 2009 at 20:36 JustenJusten 4,8699 gold badges46 silver badges69 bronze badges 2- 1 Oh there surely will be accidents. If the user clicked the button by accident, he will get confused and click through your dialog by accident... – EFraim Commented Nov 22, 2009 at 20:40
-
The underlying JavaScript function that you want is
confirm("orly?");
– Justin Johnson Commented Nov 22, 2009 at 21:45
2 Answers
Reset to default 5Here is a button with a confirmation message :
<asp:Button runat="server" ID="btnDelete"
OnClick="btnDelete_Click"
OnClientClick="return confirm('Do you want to delete the record ? ');" />
Here is the way to add confirm client script at server side :
btnDelete.Attributes.Add("onclick",
"return confirm('Do you want to delete the record ? ');")
Adding Client-Side Message Boxes in your ASP.NET Web Pages is a great tutorial to make client-side confirmation messages like this:
Using ASP.NET & VB.NET (Don't forget to read part2.)
本文标签: aspnetHow to ask the user for confirmation of an action with a popup boxStack Overflow
版权声明:本文标题:asp.net - How to ask the user for confirmation of an action with a popup box? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745410672a2657454.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论