如何检查用户是否实际点击了“保存"?而不是“取消"? [英] How can I check whether the user actually clicked "save" and not "cancel"?

查看:84
本文介绍了如何检查用户是否实际点击了“保存"?而不是“取消"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查用户是否实际单击了保存"而不是取消"?

可以很好地下载文件,但是在用户保存文件之后,我需要写入数据库,但是如果他们单击取消"并且不实际保存文件,则不想写入该文件.

基本上像这样:

How can I check whether the user actually clicked "save" and not "cancel"?

Files can be downloaded fine but I need to write to a Database after the user saves a file but dont want to write to it if they click cancel and dont actually save the file.

Basically something like:

Response.ContentType = "application/ms-excel";
Response.AddHeader("content-disposition", "inline; file1.xls");
Response.WriteFile(randomFileName); 

If(user clicked cancel)
{
    // Do nothing
}
else if (user clicked save)
{
    // write to a database
}

推荐答案

Erhm,

如果您的WebForm上有两个按钮,只需双击两个按钮. Visual Studio为您生成代码(两种方法),单击保存"时将调用一种方法,单击取消"时将调用另一种方法.

祝你好运!

爱德华
Erhm,

If you have two buttons on your WebForm, just doubleclick both of them. Visual Studio generates code for you (two methods) one method will be called when ''Save'' is clicked, the other will be called when ''Cancel'' is clicked.

Good luck!

Eduard


我不认为一旦开始,您就无法停止通过网络发布的转移.如果您使用的是FTP,那就不一样了.

要回答您的问题,只需将按钮单击处理程序添加到您的aspx页面/代码后.
I dn''t think you can''t stop a transfer via web post, once it''s started. If you were using FTP, that would be different.

To answer your question, merely add button-click handlers to your aspx page/code-behind.


ConfirmButtonExtender将是此处的快速解决方案.
ConfirmButtonExtender will be a quick solution here.


这篇关于如何检查用户是否实际点击了“保存"?而不是“取消"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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