Pergunta

I am currently in the process of migrating an old system to another server and when I tested the application, my popup windows displays a blank page. Please see below the code which is used to display my popup message:

Private Sub ShowPopUp(ByVal myID As String, ByVal request As String, ByVal windowType As String, ByVal code As String)
    Dim popupScript As String = "<script language='javascript'>" & _
                                    "window.open('NewWindow.aspx?windowType=" & windowType & "&id=" & myID & _
                                    "&code=" & code & "&popup=" & request & "&kind=3', 'CustomPopUp', " & _
                                    "'width=700, height=400, menubar=no, resizable=yes')" & _
                                "</script>"

    Page.RegisterStartupScript("PopupScript", popupScript)
End Sub

Now this used to work perfectly on the old site and on local. However, once transferred to the new server, I keep getting the warning that Page.RegisterStartupScript is obsolete and that it should be changed to Page.ClientScript.RegisterStartupScript. So I did the changes, please see below:

Page.ClientScript.RegisterStartupScript(Me.GetType(), "PopupScript", popupScript, True)

However, these doesn't work. It shows a blank page on my popup contrary to the result of running the application on my local with the 'old' way which shows my desired output.

Foi útil?

Solução

Your code should be ideally

Private Sub ShowPopUp(ByVal myID As String, ByVal request As String, ByVal windowType As String, ByVal code As String)
    Dim popupScript As String = String.Format("window.open('\NewWindow.aspx?windowType={0}&id={1}&code={2}&popup={3}&kind=3', '{4}', '{5}')",
            windowType, 
            myID, 
            code, 
            request,
            "CustomPopUp",
            "width=700, height=400, menubar=no, resizable=yes" )

    ClientScript.RegisterStartupScript("PopupScript", popupScript, True)
End Sub
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top