Sharepoint2007 EventHandler中实现页面跳转
来源:互联网 发布:linux启动过程 编辑:程序博客网 时间:2024/06/10 23:08
如果你使用ItemAdded, 你会发现你的HttpContext.Current对象是null.ItemAdded和ItemUpdated属于异步(asynchronous )事件,而HttpContext对象仅在同步(synchronous )事件中才可获取.那我们就应该使用ItemAdding了. 可是还有一个问题, 如果你使用ItemAdding事件的话, 你会发现如果执行了跳转, 你的item并不会被加入到列表中!这是因为, 一旦执行了跳转, 那么ItemAdding的线程就会被终止, item也就永远不会添加到list中了.解决方案有点麻烦, 需要你手工地添加你的item, 即在ItemAdding事件中, 手动地拿到SPList对象, 然后执行SPList.Add()方法.
代码:
public class CustomEventReceiver : SPItemEventReceiver{ private HttpContext _currentContext = null; public CustomEventReceiver () : base () { if (null != HttpContext.Current) { _currentContext = HttpContext.Current } } public override void ItemAdding (SPItemEventProperties properties) { // Get a "reference" to the list SPSite siteColl = new SPSite (properties.SiteId); SPWeb site = siteColl.OpenWeb (properties.RelativeWebUrl) ;SPList list = site.Lists[properties.ListId]; // Add the item and fill it with the values from properties DisableEventFiring (); SPListItem itemToAdd = list.Items.Add ();EnableEventFiring (); // Cleanup site.Dispose ();siteColl.Dispose (); // Redirect SPUtility.Redirect (targetUrlOfNewItem, SPRedirectFlags.Default, _currentContext); }}
- Sharepoint2007 EventHandler中实现页面跳转
- JSP中实现页面跳转
- JSP中实现页面跳转
- JS中实现页面跳转
- php中实现页面跳转
- servlet中实现页面跳转实现方法
- 在Applet中实现页面的跳转
- jsp页面中实现跳转的方式
- 在模式窗口中实现页面跳转
- 在模式窗口中实现页面跳转 .
- Flex中实现Flex页面跳转
- js代码中实现页面跳转
- 在模式窗口中实现页面跳转 .
- C#在winform中页面跳转实现
- Flex中实现“页面跳转”效果
- 在servlet中实现页面跳转
- js 中实现页面跳转的方法
- iOS应用开发中实现页面跳转
- (精)java:生成文件下载的中文名乱码解决
- 使用属性时造成的死循环
- GPIO control app
- 学习心得之ARM (STM32F207)
- Google swiffy 转换Flash(swf)到HTML5的工具
- Sharepoint2007 EventHandler中实现页面跳转
- QTreeWidgetItem 设置背景色|背景颜色
- 让html中的td自动换行
- javascript学习笔记
- Lambda表达式
- opencv 图片旋转90度
- 解决No tests found in JUnit 4测试类
- (转)memcached简介与开发应用
- android GridView 拖拽Item及滚屏实现