是否可以从共享函数中打开一个新窗口?在启动的行上有一个编译时错误: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发布于 2014-09-24 16:19:06
这是服务器端代码。服务器端代码永远不能直接打开新窗口.它所能做的就是创建一个http响应,该响应会导致一些javascript打开一个新窗口。WebMethods也不能自己直接调用javascript。您需要调用站点上的代码,以便根据方法的结果调用javascript。
另外:首先要注意Shared方法在ASP.Net中的应用。它们在应用程序域级别上共享数据,在ASP.Net中,站点的所有用户都在同一个应用程序域中。
https://stackoverflow.com/questions/26021593
复制相似问题