我試圖在response.redirect發生之前顯示一個確認彈出框。當我使用下面的代碼時,我從來沒有得到一個它只是重定向的彈出窗口。任何想法我失蹤?消息框不能與頁面重定向
Try
Dim msg As String = "Hello!"
Dim script As String = "alert('" & msg & "');"
script += "window.location.href ='frmSummary.aspx'"
'Navigate to Page 2
'Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "SCRIPT", script,true);
System.Web.UI.ScriptManager.RegisterClientScriptBlock(Me, Me.[GetType](), "Test", script, True)
Catch ex As Exception
End Try
Response.Redirect("~/frmMain.aspx")
你的VB代碼在服務器上執行。在任何代碼被髮送到客戶端之前,重定向發生。 –