使用ok创建一个消息框并取消asp.net

时间:2017-03-21 16:46:34

标签: javascript asp.net vb.net

在我的网页中,我有这个javascript向用户显示一个消息框

  Private Sub MessageBox(ByVal msg As String)
        Dim lbl As New Label

        lbl.Text = "<script language='javascript'>" & Environment.NewLine &
           "window.alert('" + msg + "');" & Environment.NewLine &
           "document.location = 'Clinica.aspx';</script>"
        Page.Controls.Add(lbl)
    End Sub

我想知道的是,是否可以放入&#34; ok&#34;和&#34;取消&#34;按钮所以在vb.net中会是这样的

                  MsgBox(vbCritical _
                   & "Os dados da marcação actual foram alterados!" & vbCrLf _
                   & "Mudando a marcação selecciona irá perder as alteraçãoes" & vbCrLf _
                   & vbCrLf _
                   & "Deseja continuar?", _
                   vbOKCancel, _
                    "ATENÇÃO!")

我是javascript的新手,我想知道这样的事情是否可行,谢谢。

1 个答案:

答案 0 :(得分:3)

js confirm('Confirmation text')怎么样?

https://developer.mozilla.org/en-US/docs/Web/API/Window/confirm

所以你的代码将运行如下:

 lbl.Text = "<script language='javascript'>" & Environment.NewLine &
      "if(window.confirm('" + msg + "')) document.location = 'Clinica.aspx';</script>"