在 ItemAdding 事件中进行验证后,向 SharePoint 文档库中的用户显示成功消息

发布于 2024-08-02 18:32:52 字数 474 浏览 13 评论 0原文

在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦言归人 2024-08-09 18:32:52

在事件处理程序中,您有一个名为 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.

终止放荡 2024-08-09 18:32:52

嗯...编辑 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文