这可能很简单,但Google中的搜索字词会产生太多不相干的结果。
Protected Sub Menu1_MenuItemClick(sender As Object, e As MenuEventArgs) Handles Menu1.MenuItemClick
If e.Item.Text = "SomeItem" Then
'The link goes here
End If
End Sub
答案 0 :(得分:2)
如果要将当前页面发送到新网址,请使用Response.Redirect
:
Protected Sub Menu1_MenuItemClick(sender As Object, e As MenuEventArgs) Handles Menu1.MenuItemClick
If e.Item.Text = "SomeItem" Then
Response.Redirect("http://www.stackoverflow.com")
End If
End Sub
要在新窗口/标签页中打开新网址,您必须使用javascript。通常我建议只将javascript直接放到aspx页面上,但如果url将使用后面代码中的数据生成url,则可以使用ClientScript.RegisterStartupScript
函数。
Protected Sub Menu1_MenuItemClick(sender As Object, e As MenuEventArgs) Handles Menu1.MenuItemClick
If e.Item.Text = "SomeItem" Then
Dim sURL As String = "http://www.stackoverflow.com"
ClientScript.RegisterStartupScript(Me.GetType(), "script", "window.open('" & sURL + "', 'popup_window');", True)
End If
End Sub