【问题标题】:Confirmation Box on specific button click单击特定按钮上的确认框
【发布时间】:2015-03-16 14:55:24
【问题描述】:

当用户点击我网页上的“保存”按钮时,我需要弹出一个确认框。每当用户点击任何按钮时,我都会显示一个确认框。我严格要求它。我需要它链接到的按钮称为 btnsavesurvey。

这是我当前在 page_load 中的代码:

Dim message As String = "Do you want to complete survey?"

    Dim sb As New System.Text.StringBuilder()

    sb.Append("return confirm('")

    sb.Append(message)

    sb.Append("');")

    ClientScript.RegisterOnSubmitStatement(Me.GetType(), "alert", sb.ToString())

【问题讨论】:

    标签: javascript asp.net


    【解决方案1】:
    $('#btnsavesurvey').click(function(){
          var r = confirm("Your message");
          if (r == true) {
             alert("You pressed OK!");
              // Do something when the user pressed ok
          } else {
              alert("You pressed Cancel!");
              // Do something when the user pressed cancel
          };
    
     });
    

    如果你的 btns id 是 btnsavesurvey,如果它的类是 btnsavesurvey 则使用 .btnsavesurvey

    【讨论】:

    • 斯文,我能得到更多关于这个答案的说明吗?另外,我需要将您发送的内容转换为 VB 而不是 C#。谢谢。
    • 你使用asp对吗?您可以在您的视图中使用 来运行 javascript。
    • @JonVisconti 更新了答案,以便您知道将操作放在哪里来处理决定
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多