您的位置:首页 > 其它

记录一个关于在event receiver中执行页面跳转的问题

2010-04-07 22:04 841 查看
问题描述 =========== 想要在某个列表添加完一个列表项之后跳转到某个特定的页面上. 这个功能可以使用Event Receiver来做到. 进一步的问题

===========
如果你使用ItemAdded, 你会发现你的HttpContext.Current对象是null.

ItemAdded和ItemUpdated属于异步(asynchronous )事件, 而HttpContext对象仅在同步(synchronous )事件中才可获取.

那我们就应该使用ItemAdding了. 可是还有一个问题, 如果你使用ItemAdding事件的话, 你会发现如果执行了跳转, 你的item并不会被加入到列表中!

这是因为, 一旦执行了跳转, 那么ItemAdding的线程就会被终止, item也就永远不会添加到list中了.

解决方案有点麻烦, 需要你手工地添加你的item, 即在ItemAdding事件中, 手动地拿到SPList对象, 然后执行SPList.Add()方法.

具体的解决方案, 请看这里.

Redirecting User on ItemAdding in SharePoint EventHanlders

http://www.bronios.com/index.php/2008/09/01/redirecting-user-on-itemadding-in-sharepoint-eventhanlders/

Redirecting from NewForm.aspx to DispForm.aspx after creating a new item

http://www.entwicklungsgedanken.de/2008/03/27/redirecting-from-newformaspx-to-dispformaspx-after-creating-a-new-item/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐