Moss开发中遇到的问题汇总
一 、 EventHandler中遇到的问题
1 在一个list中,若修改list中的值。触发ItemUpdating 事件,若某个字段是是LookUP 类型,则properties.ListItem["字段名称"] 和
properties.AfterProperties["字段名称"] 则会有所差异。properties.ListItem["字段名称"] 显示是key+Value,而properties.AfterProperties["字段名称"] 显示的是key,不论这个值是否发生过变化。
list表定义如下:
代码如下:
取到的值如下:
最近我发现了老外也遇到了相同的郁闷问题,他写了个Post,请参考
2、 在ItemAdding事件中怎样获取contentType
contentType的值得一种获取方式为properties.ListItem.ContentType.Name,但是在ItemAdding事件中,properties.ListItem的值为null如下图
遇到这种问题的解决方案为:string contentTypeName =properties.AfterProperties["ContentType"].ToString() 这样我们就可以获取到ContentTypeName。