在 ItemAdding 事件中进行验证后,向 SharePoint 文档库中的用户显示成功消息
在 ItemAdding 事件中验证文档时,有多种方法可以向用户显示错误,但似乎没有一种方法可以向用户显示成功,例如验证成功。在文档库顶部向用户发送信息消息会很棒。
public class MyItemEventReceiver : SPItemEventReceiver {
public MyItemEventReceiver() {}
public override void ItemAdding(SPItemEventProperties properties) {
// Do some validation
// If successful display message to user - can't seem to do
// If unsuccessful cancel and go to the error page - easy
}
}
}
When validating a document in the ItemAdding event there are many ways to display errors to the user, but there doesn't seem to be a way to display successes to user, like a validation was successful. An info message to the user at the top of document library would be great.
public class MyItemEventReceiver : SPItemEventReceiver {
public MyItemEventReceiver() {}
public override void ItemAdding(SPItemEventProperties properties) {
// Do some validation
// If successful display message to user - can't seem to do
// If unsuccessful cancel and go to the error page - easy
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在事件处理程序中,您有一个名为 Cancel 的属性,当设置为 true 时,它会将您重定向到错误页面。然而,当您不分发它时,它会将您重定向到文档的元数据页面,即它将为您提供文档的名称和标题。据说开箱即用是不可能存档您想做的事情的。我建议的一种替代方法是,一旦验证成功,在列表的会话/属性包中设置一个标志,并以文档 GUID 作为键,并在最终登陆页面中部署一个自定义 Web 部件,该部件将检查此GUID,如果有值,则会显示消息。
In the event handler you have a Property called Cancel when set to true it will redirect you to the Error Page. Whereas when you dont distrub it, it will redirect you to the Metadata page of the document, i.e it will as you for the Name and Title of the document. Being said that out of the Box it is not possible to archive what you want to do. One alternate approach I would suggest is that once the validation is successful, set a Flag in the Session / Property Bag of the List with the Document GUID as the Key and in the Final Landing page deploy a Custom Web Part that will check for the this GUID and if there is a Value then It will display the Message.
嗯...编辑 List 的 AllItems.aspx 或编辑您的母版页,向其中添加 Literal 控件。在 ItemAdded 事件中,只需引用该控件并设置其值。
也许事实证明您甚至需要该母版页的代码隐藏。请参阅此处。
Umm... edit List's AllItems.aspx or edit your masterpage, add Literal control to it. At ItemAdded event just refer to that control and set it's value.
Maybe it turns out you even need code-behind for that masterpage. Refer here.