简体   繁体   中英

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

So this is what i'm trying to do, i have a web application that deletes a physical file and the file record in the database. I am trying to find a way to prompt the user to see whether they want to delete the record in the db if the physical file is missing ...

using ASP.NET, here's where i'm getting stuck ...

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

is there a way to get the value from the popup back?

thanks Daniel

Create an Aspx that prompts the user to confirm deletion.

Open it in a new tab/browser/window by whatever means you choose.

This article address' your question perfectly :

eggheadcafe.com

You could add a javascript confirm to the OnClientClick event of the delete button. If the column with the delete in it is not already a template column you will have to convert it to one so you have access to the button control markup.

It might be possible to do this with without converting to a template column, but you would probably have to jump though a few more hoops to find the delete button and insert the code.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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