从单个按钮单击打开多个浏览器选项卡:ASP.NET

时间:2016-06-22 10:36:14

标签: javascript asp.net vb.net

嗨我有以下VB代码,当条件为真时,期望同时打开2个选项卡。但不幸的是,它打开了第一个标签,第二个标签没有打开。请建议

If m_strIdNumber <> 0 AndAlso UserValNum <> 0 Then
        ' is working 
        Dim url As String = MainURL + "?qs=" + m_strIdNumber + "&usr=" + "local"
        Dim script As String = String.Format("window.open('{0}');", url)
        Page.ClientScript.RegisterStartupScript(Me.GetType(), "newPage" + UniqueID, script, True)

        ' But this is not working 
        Dim url1 As String = MainURL + "?qs=" + UserValNum + "&usr=" + "local"
        Dim script As String = String.Format("window.open('{0}');", url1)
        Page.ClientScript.RegisterStartupScript(Me.GetType(), "newPage" + UniqueID, script, True)
        End If

1 个答案:

答案 0 :(得分:0)

来自msdn“具有相同密钥和类型的脚本被视为重复。只有一个具有给定类型和密钥对的脚本可以在页面中注册。”

因此,您需要为RegisterStartupScript调用两个唯一键。例如

Page.ClientScript.RegisterStartupScript(Me.GetType(), "newPage1" + UniqueID, script, True)
' ...
Page.ClientScript.RegisterStartupScript(Me.GetType(), "newPage2" + UniqueID, script, True)