繁体   English   中英

如何通过ASP.NET显示弹出对话框并获取弹出窗口的值

[英]How to show a pop-up dialog through ASP.NET and get the value of the pop up back

所以这就是我想要做的,我有一个Web应用程序,该应用程序删除物理文件和数据库中的文件记录。 我正在尝试找到一种方法来提示用户,如果缺少物理文件,则是否要删除数据库中的记录...

使用ASP.NET,这就是我被卡住的地方...

protected void gridViewDeletingRow(...) {
  // get the row to delete
  bool bdelete = deleteFile();

  if(bdelete)
     deleteRecordinDB();
     ScriptManager.RegisterStartupScript(Page, typeof(Page), Guid.NewGuid().ToString(), "javascript:alert('Document deleted successfully!');", true);
  else 
     ScriptManager.RegisterStartupScript(Page, typeof(Page), Guid.NewGuid().ToString(), "javascript:if(!fnConfirmDeleteRecord()){return false};", true);
     // i wanted to able to get the fnConfirmDeleteRecord value back here 
     // so that i can delete the file ... 
     // is there a way to do that?
   }

有没有办法从弹出窗口中获取值?

谢谢丹尼尔

创建一个Aspx,提示用户确认删除。

无论您选择哪种方式,都可以在新标签页/浏览器/窗口中打开它。

本文完美地解决了您的问题:

eggheadcafe.com

您可以将JavaScript确认添加到删除按钮的OnClientClick事件。 如果其中包含删除的列还不是模板列,则必须将其转换为一个,以便可以访问按钮控件标记。

可能无需转换为模板列即可完成此操作,但是您可能不得不跳几圈才能找到删除按钮并插入代码。

<asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete" OnClientClick="return confirm('Are you certain you want to delete this item?');"> </asp:LinkButton>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM