是否可以从共享功能打开新窗口?开始的行上有编译时错误:Response.Write
:
<System.Web.Services.WebMethod()> _
Public Shared Function UpdateTimeBasedDisposal(ByVal usn As String, ByVal strCon As String, ByVal decision As String, ByVal review As String) As String
Dim boolDecision As Boolean = CType(decision, Boolean)
Dim objNominal As New clsPrimaryNominal(strCon)
Dim strUpdateTimeBasedDisposal As String = ""
Dim objReview As New clsReviews(ConfigurationManager.ConnectionStrings("GeniedbConnection").ConnectionString), tyReview As New typeReview, intTotal As Integer, intDisposalTotal As Integer, intType As Integer
If boolDecision Then
If objNominal.MakeTimeBased(CInt(usn)) < 1 Then
strUpdateTimeBasedDisposal = "THERE WAS A PROBLEM MAKING THE NOMINAL RECORD FOR " & usn & " TIME BASED DISPOSAL." & vbCrLf
Else
strUpdateTimeBasedDisposal = "The Primary Nominal was successfully put into time based disposal"
End If
Else
If objNominal.MakeNotTimeBased(CInt(usn)) < 1 Then
strUpdateTimeBasedDisposal = "THERE WAS A PROBLEM MAKING THE NOMINAL RECORD FOR " & usn & " NOT TIME BASED DISPOSAL." & vbCrLf
Else
strUpdateTimeBasedDisposal = "The Primary Nominal was successfully taken out of time based disposal"
' next thing to do is create all the disposal records
'CreateDisposals()
intType = objReview.ReviewType(CLng(review), intTotal, intDisposalTotal)
Response.Write("<script>window.open('frmNRAC.aspx?USN=" & CStr(Session("PNUSN")) & "&Review=" & CStr(Session("Review")) & "&Total=" & intTotal & "&Disposals=" & intDisposalTotal & "','_blank')</script>")
End If
End If
Return strUpdateTimeBasedDisposal
End Function
答案 0 :(得分:2)
这是服务器端代码。服务器端代码永远不会直接打开一个新窗口。它所能做的只是创建一个http响应,导致一些 javascript 打开一个新窗口。 WebMethods也无法直接调用javascript。您需要在调用网站上为webmethod调用基于方法结果的javascript调用代码。
此外:首先要注意ASP.Net中的Shared
方法。它们在应用程序域级别共享数据,而在ASP.Net中,您站点的所有用户都在同一个应用程序域中。