Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/456.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JavaScript上的MessagBox Protected Sub listView1u ItemCommand(ByVal sender作为对象,ByVal e作为System.Web.UI.WebControls.ListViewCommandEventArgs)处理ListView1.ItemCommand “…请查看更多信息;用于添加到购物车的atcr Dim var As String=e.CommandArgument.ToString 尺寸类型为字符串=左(变量,4) Dim ItemID为String=Replace(变量,类型,“”) 'Dim ad As LinkButton=CType(ListView1.FindControl(“addToCart”),LinkButton) Dim myStringVariable As String=“在向购物车添加任何内容之前,您需要先登录!” 如果type=“vwmr”则“……转到查看更多页面…”。。。。 Dim url作为字符串=“~/indivatedEmpage\u aspx/indivatedEmpage.aspx?typeOfItem=“&_ Request.QueryString(“typeOfItem”)和“&itemID=”&itemID 重定向(url,True) ElseIf type=“atcr”然后将物品添加到购物车中。。。。。 如果User.Identity.Name=”“,则 Response.Write(“window.alert(“+myStringVariable+”)”) 'ClientScript.RegisterStartupScript(Me.[GetType](),“myalert”_ “警报(“+myStringVariable+”);“+_ “'document.location='”+ResolveUrl(“~/login.aspx”)+“;”,True) “”MsgBox(“在向购物车添加任何内容之前,您需要先登录!”,“”) 'Response.Write(“警报('Hello')”) 'ServerAlert.Show() 'ClientScript.RegisterStartupScript(Me.[GetType](),'myalert','alert(''“+myStringVariable+”);“,True) 'ad.Attributes.Add(“onclick”_ ““返回确认('您确定要删除吗?');”) 'Alert.Show(“在向购物车添加任何内容之前,您需要先登录!”) 'MessageBox1.ShowInfo(“在向购物车添加任何内容之前,您需要先登录!”,300400) 'Response.Redirect(“~/login.aspx”,True) 其他的 “……从数据库中提取详细信息……”。。。。。。。。。。 Dim con作为新的SqlClient.SqlConnection(“数据源=。\SQLEXPRESS;”&_ “AttachDbFilename=| DataDirectory |\database.mdf;”&_ “集成安全性=真;用户实例=真”) 将sql设置为新的SqlClient.SqlCommand(“SELECT*FROM”&typeOfItems&“WHERE”&_ “itemID=”&itemID&“”,con) 作为SqlClient.SqlDataReader的Dim读取器 con.Open() reader=sql.ExecuteReader reader.Read() Dim itemName作为String=reader.Item(“itemName”) Dim itemPrice作为字符串=reader.Item(“我们的价格”) 作为字符串的低报价 如果reader.Item(“offer”).ToString=“”则 offer=“” 其他的 报价=读卡器项目(“报价”) 如果结束 con.Close() '....................................................... Dim userID作为字符串=User.Identity.Name Dim sCart=新购物车 如果sCart.CheckIfItemPresent(userID、ItemID、itemPrice、offer)=True,则 出口接头 如果结束 Dim buyNo As String=sCart.findLatestBuyNo(userID) 会话(“buyNo”)=buyNo Session(“buyNo”)=sCart.AddToCart(ItemID、itemName、itemPrice、offer、buyNo、userID) 如果结束 如果结束 端接头_Javascript_.net_Asp.net_Vb.net_Messagebox - Fatal编程技术网

JavaScript上的MessagBox Protected Sub listView1u ItemCommand(ByVal sender作为对象,ByVal e作为System.Web.UI.WebControls.ListViewCommandEventArgs)处理ListView1.ItemCommand “…请查看更多信息;用于添加到购物车的atcr Dim var As String=e.CommandArgument.ToString 尺寸类型为字符串=左(变量,4) Dim ItemID为String=Replace(变量,类型,“”) 'Dim ad As LinkButton=CType(ListView1.FindControl(“addToCart”),LinkButton) Dim myStringVariable As String=“在向购物车添加任何内容之前,您需要先登录!” 如果type=“vwmr”则“……转到查看更多页面…”。。。。 Dim url作为字符串=“~/indivatedEmpage\u aspx/indivatedEmpage.aspx?typeOfItem=“&_ Request.QueryString(“typeOfItem”)和“&itemID=”&itemID 重定向(url,True) ElseIf type=“atcr”然后将物品添加到购物车中。。。。。 如果User.Identity.Name=”“,则 Response.Write(“window.alert(“+myStringVariable+”)”) 'ClientScript.RegisterStartupScript(Me.[GetType](),“myalert”_ “警报(“+myStringVariable+”);“+_ “'document.location='”+ResolveUrl(“~/login.aspx”)+“;”,True) “”MsgBox(“在向购物车添加任何内容之前,您需要先登录!”,“”) 'Response.Write(“警报('Hello')”) 'ServerAlert.Show() 'ClientScript.RegisterStartupScript(Me.[GetType](),'myalert','alert(''“+myStringVariable+”);“,True) 'ad.Attributes.Add(“onclick”_ ““返回确认('您确定要删除吗?');”) 'Alert.Show(“在向购物车添加任何内容之前,您需要先登录!”) 'MessageBox1.ShowInfo(“在向购物车添加任何内容之前,您需要先登录!”,300400) 'Response.Redirect(“~/login.aspx”,True) 其他的 “……从数据库中提取详细信息……”。。。。。。。。。。 Dim con作为新的SqlClient.SqlConnection(“数据源=。\SQLEXPRESS;”&_ “AttachDbFilename=| DataDirectory |\database.mdf;”&_ “集成安全性=真;用户实例=真”) 将sql设置为新的SqlClient.SqlCommand(“SELECT*FROM”&typeOfItems&“WHERE”&_ “itemID=”&itemID&“”,con) 作为SqlClient.SqlDataReader的Dim读取器 con.Open() reader=sql.ExecuteReader reader.Read() Dim itemName作为String=reader.Item(“itemName”) Dim itemPrice作为字符串=reader.Item(“我们的价格”) 作为字符串的低报价 如果reader.Item(“offer”).ToString=“”则 offer=“” 其他的 报价=读卡器项目(“报价”) 如果结束 con.Close() '....................................................... Dim userID作为字符串=User.Identity.Name Dim sCart=新购物车 如果sCart.CheckIfItemPresent(userID、ItemID、itemPrice、offer)=True,则 出口接头 如果结束 Dim buyNo As String=sCart.findLatestBuyNo(userID) 会话(“buyNo”)=buyNo Session(“buyNo”)=sCart.AddToCart(ItemID、itemName、itemPrice、offer、buyNo、userID) 如果结束 如果结束 端接头

JavaScript上的MessagBox Protected Sub listView1u ItemCommand(ByVal sender作为对象,ByVal e作为System.Web.UI.WebControls.ListViewCommandEventArgs)处理ListView1.ItemCommand “…请查看更多信息;用于添加到购物车的atcr Dim var As String=e.CommandArgument.ToString 尺寸类型为字符串=左(变量,4) Dim ItemID为String=Replace(变量,类型,“”) 'Dim ad As LinkButton=CType(ListView1.FindControl(“addToCart”),LinkButton) Dim myStringVariable As String=“在向购物车添加任何内容之前,您需要先登录!” 如果type=“vwmr”则“……转到查看更多页面…”。。。。 Dim url作为字符串=“~/indivatedEmpage\u aspx/indivatedEmpage.aspx?typeOfItem=“&_ Request.QueryString(“typeOfItem”)和“&itemID=”&itemID 重定向(url,True) ElseIf type=“atcr”然后将物品添加到购物车中。。。。。 如果User.Identity.Name=”“,则 Response.Write(“window.alert(“+myStringVariable+”)”) 'ClientScript.RegisterStartupScript(Me.[GetType](),“myalert”_ “警报(“+myStringVariable+”);“+_ “'document.location='”+ResolveUrl(“~/login.aspx”)+“;”,True) “”MsgBox(“在向购物车添加任何内容之前,您需要先登录!”,“”) 'Response.Write(“警报('Hello')”) 'ServerAlert.Show() 'ClientScript.RegisterStartupScript(Me.[GetType](),'myalert','alert(''“+myStringVariable+”);“,True) 'ad.Attributes.Add(“onclick”_ ““返回确认('您确定要删除吗?');”) 'Alert.Show(“在向购物车添加任何内容之前,您需要先登录!”) 'MessageBox1.ShowInfo(“在向购物车添加任何内容之前,您需要先登录!”,300400) 'Response.Redirect(“~/login.aspx”,True) 其他的 “……从数据库中提取详细信息……”。。。。。。。。。。 Dim con作为新的SqlClient.SqlConnection(“数据源=。\SQLEXPRESS;”&_ “AttachDbFilename=| DataDirectory |\database.mdf;”&_ “集成安全性=真;用户实例=真”) 将sql设置为新的SqlClient.SqlCommand(“SELECT*FROM”&typeOfItems&“WHERE”&_ “itemID=”&itemID&“”,con) 作为SqlClient.SqlDataReader的Dim读取器 con.Open() reader=sql.ExecuteReader reader.Read() Dim itemName作为String=reader.Item(“itemName”) Dim itemPrice作为字符串=reader.Item(“我们的价格”) 作为字符串的低报价 如果reader.Item(“offer”).ToString=“”则 offer=“” 其他的 报价=读卡器项目(“报价”) 如果结束 con.Close() '....................................................... Dim userID作为字符串=User.Identity.Name Dim sCart=新购物车 如果sCart.CheckIfItemPresent(userID、ItemID、itemPrice、offer)=True,则 出口接头 如果结束 Dim buyNo As String=sCart.findLatestBuyNo(userID) 会话(“buyNo”)=buyNo Session(“buyNo”)=sCart.AddToCart(ItemID、itemName、itemPrice、offer、buyNo、userID) 如果结束 如果结束 端接头,javascript,.net,asp.net,vb.net,messagebox,Javascript,.net,Asp.net,Vb.net,Messagebox,我想用javascript警报替换asp.netMsgBox,我该怎么做?注释掉的行是我已经试用过的…请帮助我…紧急。发布网站后,asp.netMsgBox在客户端不起作用。尝试以下方法: Protected Sub ListView1_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewCommandEventArgs) Handles ListView1.ItemCommand

我想用javascript警报替换asp.net
MsgBox
,我该怎么做?注释掉的行是我已经试用过的…请帮助我…紧急。发布网站后,asp.net
MsgBox
在客户端不起作用。

尝试以下方法:

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
private void警报(字符串消息)
{
Response.Write(“window.alert(“+Msg+”)”);
}
如果您想要一条很酷的消息,请尝试。

尝试以下方法:

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
private void警报(字符串消息)
{
Response.Write(“window.alert(“+Msg+”)”);
}

如果您想要一条很酷的消息,请尝试。

不要使用
响应。重定向
。它阻止执行当前页面。改用javascript中的
window.location.href
。以下是您可能会做的:

private void alert(string Msg)
{
    Response.Write("<script type='text/javascript'>window.alert('" + Msg + "')</script>");
}

不要使用
响应。重定向
。它阻止执行当前页面。改用javascript中的
window.location.href
。以下是您可能会做的:

private void alert(string Msg)
{
    Response.Write("<script type='text/javascript'>window.alert('" + Msg + "')</script>");
}

您正在最后一行调用
Response.Redirect(“~/login.aspx”,True)
,这意味着警报javascript甚至从未发送到客户端。要允许显示警报框,还必须在客户端上通过在警报后设置
document.location
,而不是使用
Response.redirect
,进行重定向

像这样:

ClientScript.RegisterStartupScript(Me.[GetType](), "myalert",   
"alert('" + myStringVariable + "'); document.location = 'login.aspx';", True)

(不确定代码是否有效,我通常编写C#)

您在最后一行调用的是
Response.Redirect(“~/login.aspx”,True)
,这意味着javascript警报从未发送到客户端。要允许显示警报框,还必须在客户端上通过在警报后设置
document.location
,而不是使用
Response.redirect
,进行重定向

像这样:

ClientScript.RegisterStartupScript(Me.[GetType](), "myalert",   
"alert('" + myStringVariable + "'); document.location = 'login.aspx';", True)

(不确定代码是否有效,我通常编写C#)

ClientScript.RegisterStartupScript
是正确的方法-尝试时会发生什么?有错误吗?当他在最后重定向时,注册的客户端脚本将不会执行。当我使用
ClientScript.RegisterStartupScript
时,什么也不会发生。它会直接转到登录页面。@Monodeep:@Uwe Keim已经提到:如果你
响应。重定向到另一个页面,则不会执行当前页面。您可以做的是:使用cl扩展警报