Protected Sub ListView1_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewCommandEventArgs) Handles ListView1.ItemCommand
'...vwmr for view more; atcr for add to cart
Dim var As String = e.CommandArgument.ToString
Dim type As String = Left(var, 4)
Dim ItemID As String = Replace(var, type, "")
'Dim ad As LinkButton = CType(ListView1.FindControl("addToCart"), LinkButton)
Dim myStringVariable As String = "You need to login first before adding anything to the cart!"
If type = "vwmr" Then '........go to view more page....
Dim url As String = "~/dedicatedItemPage_aspx/dedicatedItemPage.aspx?typeOfItem=" & _
Request.QueryString("typeOfItem") & "&itemID=" & ItemID
Response.Redirect(url, True)
ElseIf type = "atcr" Then '..........add the item to the cart.....
If User.Identity.Name = "" Then
Response.Write("<script type='javascript'>window.alert('" + myStringVariable + "')</script>")
' ClientScript.RegisterStartupScript(Me.[GetType](), "myalert", _
'"alert('" + myStringVariable + "');" + _
'"document.location = '" + ResolveUrl("~/login.aspx") + "';", True)
' 'MsgBox("You need to login first before adding anything to the cart!", , "")
'Response.Write("<script>alert('Hello')</script>")
'ServerAlert.Show()
'ClientScript.RegisterStartupScript(Me.[GetType](), "myalert", "alert('" + myStringVariable + "');", True)
'ad.Attributes.Add("onclick", _
' "return confirm('Are you sure you want to delete?');")
'Alert.Show("You need to login first before adding anything to the cart!")
'MessageBox1.ShowInfo("You need to login first before adding anything to the cart!", 300, 400)
'Response.Redirect("~/login.aspx", True)
Else
'..........pull details from database..........
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("SELECT * FROM " & typeOfItems & " WHERE " & _
"itemID = '" & ItemID & "'", con)
Dim reader As SqlClient.SqlDataReader
con.Open()
reader = sql.ExecuteReader
reader.Read()
Dim itemName As String = reader.Item("itemName")
Dim itemPrice As String = reader.Item("ourPrice")
Dim offer As String
If reader.Item("offer").ToString = "" Then
offer = ""
Else
offer = reader.Item("offer")
End If
con.Close()
'.......................................................
Dim userID As String = User.Identity.Name
Dim sCart = New cart
If sCart.CheckIfItemPresent(userID, ItemID, itemPrice, offer) = True Then
Exit Sub
End If
Dim buyNo As String = sCart.findLatestBuyNo(userID)
Session("buyNo") = buyNo
Session("buyNo") = sCart.AddToCart(ItemID, itemName, itemPrice, offer, buyNo, userID)
End If
End If
End Sub
i want to replace the asp.net MsgBox
with javascript alert...how can i do that? the commented out lines are the once i have already tried out...please help me ...urgent.the asp.net MsgBox
does not work on client side after publishing the website.