JavaScript 确认框?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Javascript 没有直接替代品可以做到这一点。
要与用户交互,您必须将响应发送回可以显示的浏览器,然后用户可以做出选择并向服务器发送另一个包含有关该选择的信息的请求。
因此,您必须在服务器端将其分为两个单独的步骤。
要在 Javascript 中创建确认框,您可以使用
confirm
方法。例子: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: