开发者

javascript confirmation box? [closed]

开发者 https://www.devze.com 2023-03-05 20:08 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical andcannot be reasonably answered in its current form. For help clari
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.
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 Fals开发者_如何学Ce
    End Function

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


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');
0

精彩评论

暂无评论...
验证码 换一张
取 消