代码之家  ›  专栏  ›  技术社区  ›  aggietech

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

  •  0
  • aggietech  · 技术社区  · 14 年前

    所以这就是我要做的,我有一个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?
       }
    

    谢谢

    2 回复  |  直到 14 年前
        1
  •  1
  •   BentOnCoding    14 年前

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

    在新的选项卡/浏览器/窗口中以任何方式打开它。

    eggheadcafe.com

        2
  •  0
  •   Chris Mullins    14 年前

    您可以将javascript confirm添加到delete按钮的OnClientClick事件中。如果包含delete的列不是模板列,则必须将其转换为模板列,以便可以访问按钮控件标记。

    在不转换为模板列的情况下,可以这样做,但是您可能需要跳转几个圈才能找到delete按钮并插入代码。

    <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>