I want to transition from aspx(ASP.NET 4.0) page to html page.

Asked 2 years ago, Updated 2 years ago, 132 views

Below is a web page created by ASP.NET (VB.NET), but when the image button is pressed, I would like to open html on a completely different site depending on the value of the session variable.(If the session variable is not 2)
How can I move the JS that starts window.open?
The screen does not open below

Protected Sub ImageButton2_Click (ByVal sender As Object, ByVale As System.Web.UI.ImageClickEventArgs)
        If Session("UserLevel")<"2" Then
            Dim startupScript As String="<scriptlanguage='JavaScript'>window.open('http://XXXXXXXXX/XXXXX/logon.html')</Script>"
            Page.RegisterStartupScript("startup", startupScript)
        Else
            Server.Transfer ("Menu2.aspx")
        End If
    End Sub

javascript asp.net

2022-09-30 21:31

1 Answers

UserLevel does not change between page display and click.

Instead of deciding where to jump after clicking, why don't you set the link when Page_Load?

<asp:HyperLink ID="hyperLink1"NavigateUrl="Menu2.aspx"runat="server">
    <img src="something.png"/>
</asp:HyperLink>

Protected Sub Page_Load (ByVal sender As Object, ByVal eAs System.EventArgs) Handles Me.Load
    If Session("UserLevel")<"2" Then
        hyperLink1.NavigateUrl="http://XXXXXXXX/XXXXXX/logon.html"
        hyperLink1.Target="_blank"
    End If
End Sub


2022-09-30 21:31

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.