首页 新闻 赞助 找找看

SharePoint事件接收器代码中取消操作后如何友好提示

0
悬赏园豆:40 [已关闭问题] 关闭于 2013-09-12 19:09

各位专家高手:在下为SharePoint写了一个SPItemEventReceiver,在其ItemAdding方法中设置properties.Cancel = true,本希望SharePoint会给个友好的取消操作提示,结果却是个异常提示!在事件查看器里有个未捕获的 SPException,这个异常是按我的ErrorMessage封装的。求解!

/// <summary>
/// 列表项事件
/// </summary>
public class DocumentUploadEventReceiver : SPItemEventReceiver
 {
        /// <summary>
        /// 正在添加项.
        /// </summary>
        public override void ItemAdding(SPItemEventProperties properties)
        {
            properties.ErrorMessage = "抱歉您上传的内容已超过个人使用配额!";
            properties.Status = SPEventReceiverStatus.CancelWithError;
            properties.Cancel = true;
        }
}


在网上找了一下,这个连接http://blog.csdn.net/violet_day/article/details/9203845 的提示效果是我预期的,但是我这的运行结果像这样http://www.360sps.com/Item/FiletypeRestrictionsEventReceiver.aspx 。

C#开发人员的主页 C#开发人员 | 初学一级 | 园豆:181
提问于:2013-09-05 14:23
< >
分享
所有回答(1)
1

管理工具-〉Internet 信息服务(IIS)管理器-〉网站-〉SharePoint - 80

找到web.config,修改下面的节点:

<SafeMode MaxControls="200" CallStack="false" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="false">

<customErrors mode="On" />

 

参考http://sharepoint.stackexchange.com/questions/28495/event-reciever-custom-error-message-page-sharepoint-list-2010

http://social.msdn.microsoft.com/Forums/sharepoint/en-US/9c197488-2ed1-4ffd-bd2b-91de4361728d/itemupdating-cancel-errormessage-not-shown-on-standard-sharepoint-error-page

C#开发人员 | 园豆:181 (初学一级) | 2013-09-12 19:09
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册