confirm('The system not allow negative ...">

Confirm message in ASP.NET

I wrote this entry in my code:

Response.Write("<script language=javascript>confirm('The system not allow negative inventory,continue?');</script>");

How can I transfer if the user clicked the "OK" or "Cancel" button?

+2
source share
4 answers

You must put this confirmation in your submit button as follows:

btnSubmit.Attributes["onclick"] += 
    "return confirm('The system not allow negative inventory,continue?');"

If the user cancels the cancellation, your page will not be returned.

But if you ask that you can determine the user action on the server side, the answer will be negative, not directly. You must add a trick in order to get user action. Perhaps you should set the user action in a hidden field and on the server side get this value and continue.

+2
source

Javascript, , , Javascript confirm :

var result = confirm('The system does not allow negative inventory. Continue?');
if (result == true)
  // The user wants to continue. Proceed accordingly.
else
  // The user does not want to continue.

.

+2

. , OK , script . , , - .

JavaScript :

location.href = 'Handler.aspx?confirmed=' + confirm('Do you want to do X?');

Handler.aspx?confirmed=true Handler.aspx?confirmed=false.

+1

onClientClick ( aspx)

confirm('your message');

and the onClick tag refer to a function in the code where you can write a function that will be executed only by clicking OK in the message box.

Using the javascript confirmation function, you can allow the user to confirm or click the button. If the user clicks “yes” in the message / warning window, the “Click” button will even be launched on the server. If the no button is not pressed, the event will not be fired. This is especially useful for buttons used for deletion.

button.Attributes("onclick") = "javascript:return " & _
                 "confirm('Are You Sure you want to do this operation?') "
0
source

Source: https://habr.com/ru/post/1718945/


All Articles