Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
60 views
in Technique[技术] by (71.8m points)

How to stop execution if I click "no" in asp.net using Javascript

I have a ASP.NET website to stop execute my Http post by clicking a cancel button, but my code does not abort even though User clicked Cancel Button. I used a lot of things for aborting my post, I could not find any solution. Someone said try to use Redirect but also this Redirect always execute my Post controller.

<div class="caption">
  <h5>@item.Point_Name</h5>
  <h2>@item.Point_Point</h2>
  @using (Html.BeginForm("CustomList", "Point_Item", new { productId = 
  item.Pid, url = "CustomList" }, FormMethod.Post))
  {
    <input type="submit" value="Submit" onclick="Confirm()" />
  }
</div>


<script type="text/javascript"
        src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
  function Confirm() {
      var r = confirm("Are you sure you want to buy it?");
      if (r == true) {
          txt = "You pressed OK!";
      } else {
          System.Threading.Thread.Sleep(5000);
      }
    }
</script>
question from:https://stackoverflow.com/questions/65910301/how-to-stop-execution-if-i-click-no-in-asp-net-using-javascript

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...