嗨我有以下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
答案 0 :(得分:0)
来自msdn“具有相同密钥和类型的脚本被视为重复。只有一个具有给定类型和密钥对的脚本可以在页面中注册。”
因此,您需要为RegisterStartupScript调用两个唯一键。例如
Page.ClientScript.RegisterStartupScript(Me.GetType(), "newPage1" + UniqueID, script, True)
' ...
Page.ClientScript.RegisterStartupScript(Me.GetType(), "newPage2" + UniqueID, script, True)