通过消息框处理事件触发 [英] handle event fire by message box

查看:61
本文介绍了通过消息框处理事件触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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


在出现消息框的情况下如何处理是或否?


how can handle yes or no in case of message box

推荐答案

您好,heskapil,

我想您想做这样的事情:

Hi heskapil,

I think you want to do something like that :

DialogResult result = MessageBox.Show("Are you sure you want to delete this record?", "Message", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{

}
else
    return;



希望对您有所帮助,
:)



I hope this help,
:)


解决方案很简单...

solution is simple...

<asp:Button ID="DeleteButton" runat="server" OnClientClick="return confirm('Are you sure you want to delete this ?');" Font-Bold="True" Font-Size="Large" ForeColor="Blue"
        OnClick="DeleteButton_Click" Text="Delete" ToolTip="Click here to Delete this....."
        ValidationGroup="MyPersonal" Width="98px" />


and in DeleteButton_Click event write your deleting code in C#..





受保护的void DeleteButton_Click(object sender,eventargs e)
{
在此处写下您的删除代码
}

它肯定会工作..

如果用户单击确定",则将执行删除操作

如果他单击取消,将无法执行任何操作...

试试这个...



i.e.,

protected void DeleteButton_Click(object sender,eventargs e)
{
write your deleting code here
}

it will definitely work..

if the user clicks ok then the delete action will be done

if he clicks cancel nothing will be done...

try this...


您要为事件代码设置事件处理程序吗?我认为您无法做到.它必须是一个方法(委托),然后将代码放入该方法.
You''re setting an event handler to acutal code? I don''t think you can do that. It has to be a method (delegate) and you put the code into that method.


这篇关于通过消息框处理事件触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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