我正在尝试使用Sharepoint在自定义列表中的方法itemAdded中添加项目之后重定向页面:
Public Class EventReceiver1
Inherits SPItemEventReceiver
Private current As HttpContext
Shared obj As Object
Public Sub New()
MyBase.New()
If current Is Nothing Then
current = HttpContext.Current
End If
End Sub
Public Overrides Sub ItemAdded(properties As SPItemEventProperties)
current = DirectCast(obj, HttpContext)
MyBase.ItemAdded(properties)
SPUtility.Redirect(properties.WebUrl & "/Paginas/Forms/EditForm.aspx?ID=" & properties.ListItemId, SPRedirectFlags.Trusted, current)
End Sub
Public Overrides Sub ItemAdding(properties As Microsoft.SharePoint.SPItemEventProperties)
obj = current
End Sub
End Class
尝试使用SPUtility.Redirect
但不起作用,仅适用于ItemAdding方法。
答案 0 :(得分:0)
ItemAdded是异步的,并且对库发生after an item has been added,即您已经返回到库中。所以,我怀疑你会从中获得重定向。这是未经测试的,但您始终可以使用要重定向的URL设置隐藏变量,并在客户端上使用window.location来完成相同的操作。