JavaScript 确认框?

发布于 2024-11-07 08:06:06 字数 1969 浏览 3 评论 0原文

Public Function CheckIfItemPresent(ByVal userID As String, ByVal itemID As String, ByVal itemPrice As Integer, ByVal offer As String) As Boolean
        On Error GoTo galti

        Dim sqlStatement As String = "SELECT itemQtty FROM shoppingCart WHERE userID = '" & _
                                    userID & "' AND itemID = '" & itemID & "'" & _
                                    " AND itemPrice = " & itemPrice & " AND offer = '" & offer & "'"
        Dim con As New SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;" & _
                                               "AttachDbFilename=|DataDirectory|\database.mdf;" & _
                                               "Integrated Security=True;User Instance=True")
        Dim sql As New SqlClient.SqlCommand(sqlStatement, con)
        Dim reader As SqlClient.SqlDataReader

        con.Open()
        reader = sql.ExecuteReader
        reader.Read()
        Dim itemQtty As Integer = reader.Item("itemQtty")
        reader.Close()
        If itemQtty > 0 Then
            If ***MsgBox("Item already present. Add another one? Currently, number of this item in cart: " & itemQtty, MsgBoxStyle.YesNo, "") = MsgBoxResult.Yes*** Then
                itemQtty = itemQtty + 1
                sql.CommandText = "UPDATE shoppingCart SET itemQtty = " & itemQtty & " WHERE " & _
                                    "userID = '" & userID & "' AND itemID = '" & itemID & "' AND itemPrice=" & _
                                    itemPrice & " AND offer = '" & offer & "'"
                sql.ExecuteNonQuery()
            Else
            End If
        End If
        con.Close()
        con.Dispose()
        Return True
        Exit Function
galti:
        con.Close()
        con.Dispose()
        Return False
    End Function

如何使用 javascript 构造框而不是 asp.net msgbox...请检查 * 之间的部分

Public Function CheckIfItemPresent(ByVal userID As String, ByVal itemID As String, ByVal itemPrice As Integer, ByVal offer As String) As Boolean
        On Error GoTo galti

        Dim sqlStatement As String = "SELECT itemQtty FROM shoppingCart WHERE userID = '" & _
                                    userID & "' AND itemID = '" & itemID & "'" & _
                                    " AND itemPrice = " & itemPrice & " AND offer = '" & offer & "'"
        Dim con As New SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;" & _
                                               "AttachDbFilename=|DataDirectory|\database.mdf;" & _
                                               "Integrated Security=True;User Instance=True")
        Dim sql As New SqlClient.SqlCommand(sqlStatement, con)
        Dim reader As SqlClient.SqlDataReader

        con.Open()
        reader = sql.ExecuteReader
        reader.Read()
        Dim itemQtty As Integer = reader.Item("itemQtty")
        reader.Close()
        If itemQtty > 0 Then
            If ***MsgBox("Item already present. Add another one? Currently, number of this item in cart: " & itemQtty, MsgBoxStyle.YesNo, "") = MsgBoxResult.Yes*** Then
                itemQtty = itemQtty + 1
                sql.CommandText = "UPDATE shoppingCart SET itemQtty = " & itemQtty & " WHERE " & _
                                    "userID = '" & userID & "' AND itemID = '" & itemID & "' AND itemPrice=" & _
                                    itemPrice & " AND offer = '" & offer & "'"
                sql.ExecuteNonQuery()
            Else
            End If
        End If
        con.Close()
        con.Dispose()
        Return True
        Exit Function
galti:
        con.Close()
        con.Dispose()
        Return False
    End Function

how to use javascript conformation box instead of asp.net msgbox...please check the portion in between *

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤云独去闲 2024-11-14 08:06:06

Javascript 没有直接替代品可以做到这一点。

要与用户交互,您必须将响应发送回可以显示的浏览器,然后用户可以做出选择并向服务器发送另一个包含有关该选择的信息的请求。

因此,您必须在服务器端将其分为两个单独的步骤。

要在 Javascript 中创建确认框,您可以使用 confirm 方法。例子:

var choise = window.confirm('Item already present. Add another one? Currently, number of this item in cart: 42');

There is no drop-in replacement to do that with Javascript.

To interact with the user you have to send a response back to the browser that it can display, then the user can make the choise and send another request to the server containing the information about the choise.

So, you have to divide this into two separate steps on the server side.

To make a confirmation box in Javascript you can use the confirm method. Example:

var choise = window.confirm('Item already present. Add another one? Currently, number of this item in cart: 42');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文