是否可以在删除数据记录时显示问题? [英] Is it possible to show a question befor deleting a datarecord?

查看:46
本文介绍了是否可以在删除数据记录时显示问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Guys



我在Visual Studio中创建了一个WebForm。我想在点击buttonDelete按钮后显示一个问题(文字:你确定要删除这个数据线吗? - 是 - 否 - 取消)。



可以这样做吗?





我很感激每一个帮助。

valentigra

Hello Guys

I created a WebForm in Visual Studio. I would like to show a question (Text: "Are you sure, you want to delete this datarecord?" -Yes - No - Cancel) after clicking the button "buttonDelete".

Is it possible to do this?


I appreciate every help.
valentigra

推荐答案

最简单的方法是使用HTML元素的事件 onsubmit 形式。请参阅,例如:

http://www.w3schools.com/js/js_form_validation。 asp [ ^ ]。



如您所见,如果处理程序返回false,则不会提交表单。您可以通过询问用户确认来实现此验证。获得用户确认的最简单方法是使用JavaScript 弹出 确认框。它会询问确定/取消问题,这实际上就是你要做的事情:

http://www.w3schools.com/js/js_popup.asp [ ^ ]。



你可以做更多花哨和定制的事情。首先,您可以将jQuery Dialog与模态确认一起使用: http://jqueryui.com/ dialog / #modeal-confirmation [ ^ ]。



如果您需要学习jQuery(强烈推荐),请参阅:

http://en.wikipedia.org/wiki/JQuery [ ^ ],

http://jquery.com [< a href =http://jquery.com/target =_ blanktitle =New Window> ^ ],

http://learn.jquery.com [ ^ ],

http://learn.jquery.com/using-jquery -core [ ^ ],

http://learn.jquery.com/about-jquery/how-jquery-works [ ^ ](从这里开始)。



我想我列出了所有你需要的元素。有问题吗?



-SA
The simplest way which comes to mind is using the event onsubmit of the HTML element form. Please see, for example:
http://www.w3schools.com/js/js_form_validation.asp[^].

As you can see, if the handler returns false, the form will not be submitted. You can implement this "validation" by asking a user confirmation. The simplest way to get a confirmation of the user would be using JavaScript popup confirm box. It will ask an OK/Cancel question, and this is actually what you are trying to do:
http://www.w3schools.com/js/js_popup.asp[^].

You can do anything more fancy and customized. First of all, you can use jQuery Dialog with a modal confirmation: http://jqueryui.com/dialog/#modal-confirmation[^].

If you need to learn jQuery (highly recommended), please see:
http://en.wikipedia.org/wiki/JQuery[^],
http://jquery.com[^],
http://learn.jquery.com[^],
http://learn.jquery.com/using-jquery-core[^],
http://learn.jquery.com/about-jquery/how-jquery-works[^] (start from here).

I think I listed all the elements you need. Any questions?

—SA


如果您使用的是jquery ..

http://jqueryui.com/dialog/#modal-confirmation [ ^ ]
If you are using jquery ..
http://jqueryui.com/dialog/#modal-confirmation[^]


我发现了另一种不使用javascript的解决方案或像其他解决方案一样jquery。

I found another solution without using javascript or jquery like the other solutions.
<asp:button id="_buttonDelete" runat="server" onclick="ButtonDeleteClick" text="Delete" cssclass="btn" onclientclick="return confirm('Sure you want to delete this datarecord?');" xmlns:asp="#unknown" />





此代码是我所寻找的,它显示两个按钮确定和取消。单击确定按钮后,您将进入ButtonDeleteClick功能。



This code is all I was looking for, it shows two buttons "OK" and "Cancel". After clicking the button "OK" you'll get to the function "ButtonDeleteClick".

OnClientClick="return confirm('Sure you want to delete this datarecord?');"





问候

valentigra



Greetings
valentigra


这篇关于是否可以在删除数据记录时显示问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆