Page.ClientScript.RegisterStartupScript不起作用 [英] Page.ClientScript.RegisterStartupScript does not work

查看:191
本文介绍了Page.ClientScript.RegisterStartupScript不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在迁移旧系统到另一台服务器的过程中,当我测试的应用程序,我的弹出窗口显示空白页。请参阅下面的code用来显示我的弹出消息:

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

现在,这个曾经的旧网站和当地的正常工作。然而,一旦转移到新的服务器,我不断收到警告 Page.RegisterStartupScript是过时,它应该改为 Page.ClientScript。的RegisterStartupScript 。所以我做了变更,请参阅以下内容:

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.

推荐答案

您code应该理想

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

这篇关于Page.ClientScript.RegisterStartupScript不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆