确认在asp.net Web应用程序中删除的jaacscript代码 [英] jacascript code for confirming delete in asp.net web application

查看:50
本文介绍了确认在asp.net Web应用程序中删除的jaacscript代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的gidview中有一个删除按钮,当我单击它时,它会删除该行.
现在我想使用是"或否"按钮添加对删除操作的确认.我想使用javascript.any一个人请帮助我

我不知道javascript os是更好的方法还是其他方法.

在此先谢谢您.

i have a delete button in my gidview ,when i click in it it delete the row.
now i want to add confirmation for the delete operation with ''yes'' or ''no'' button.i want to do it with javascript.any one please help me

i dont know whether javascript os better method or any one else.

Thanks in advance.

推荐答案

要在数据表上添加删除提示(看起来像是UI中的数据网格),则需要将javascript绑定到在datagrid的ItemDataBound/RowDataBound事件期间提示此警报.

在这种情况下,当数据逐行绑定时,请添加以下内容:
For adding a delete prompt on a datatable (looks like its going to be a datagrid in UI), you would need to bind the javascript to prompt for this alert during the ItemDataBound/RowDataBound event of the datagrid.

In this event, while the data is binded row by row - add something like:
LinkButton l = (LinkButton)e.Row.FindControl("LinkButton1");
l.Attributes.Add("onclick", "javascript:return " +
    "confirm(''Are you sure you want to delete this record'')"); 



或者,
如果datagrid的ItemTemplate中的链接按钮暴露了OnclientClick事件(在ASP.NET2.0及更高版本中存在),则可以添加以下内容:



Alternatively,
if the link button in ItemTemplate of datagrid has OnclientClick event exposed (which is present in ASP.NET2.0 onwards), you can add something like:

OnClientClick = ''return confirm("Are you sure you want to delete this entry?");'' 



参考: MSDN:删除时添加客户端确认 [



Refer: MSDN: Adding Client-Side Confirmation when Deleting[^]

Try!


之前已经做过很多次了.如果您已经在Google上进行过搜索,那么很可能您现在已经得到了答案.
无论如何,请看以下链接:

带有确认的GridView删除 [ http://www.techtoolblog.com/archives/adding-a- Confirm-javascript-popup-to-net-gridview [ ^ ]
It has been done so many times before. I you would have searched on Google, it''s very likely that you would have got your answer by now.
Anyways, Look at followingt links:

GridView Delete, with Confirmation[^]

http://www.techtoolblog.com/archives/adding-a-confirm-javascript-popup-to-net-gridview[^]


请通过以下链接,简单易懂.

http://forums.asp.net/t/1684080.aspx/1 [ ^ ]
Please go through below link, simple and easy to understand.

http://forums.asp.net/t/1684080.aspx/1[^]


这篇关于确认在asp.net Web应用程序中删除的jaacscript代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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