[英]Page.ClientScript.RegisterStartupScript does not work
我目前正在將舊系統遷移到另一台服務器,並且在測試應用程序時,我的彈出窗口顯示空白頁。 請在下面查看用於顯示我的彈出消息的代碼:
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 is obsolete
,應將其更改為Page.ClientScript.RegisterStartupScript
。 因此,我進行了更改,請參見以下內容:
Page.ClientScript.RegisterStartupScript(Me.GetType(), "PopupScript", popupScript, True)
但是,這些無效。 它在彈出窗口上顯示空白頁面,與使用“舊”方式在本地運行應用程序的結果相反,該方式顯示了我想要的輸出。
您的代碼應該是理想的
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.