My algorithm is as follows:

  1. Press the button in the "Delete line" grid

  2. A JS confirm message (text) and 2 buttons appear: Yes, Cancel (standard buttons)

  3. If you click on "Yes" - the line is deleted, i.e. The following code is executed after the script is executed. If "Cancel" - then do nothing.

I do like this:

 private void dg_НашГрид_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { //запустить джава-скрипт const string errorMessage = "вопрос подтверждения"; const string clientScript = "function confirmDelete() {if (confirm(" + "\"" + errorMessage + "\"" + ")) {return true;} else {return false;}}"; ClientScript.RegisterClientScriptBlock(this.GetType(), "onload", clientScript, true); //код удаления... } 

Now at performance of any question does not arise (since there is a function). if you enter the confirm (text) script, the line will be deleted first and then a message will appear whether you really want to delete the line. I was advised to wrap the result in a variable and then set a condition in the code. I can not imagine how this can be done. Can you please tell us how it is more logical to achieve your goals?

  • the whole point is that you need to execute this javascript before you go into dg_НашГрид_DeleteCommand . Add aspx grid markup - Grundy

0