Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在某些Umbraco事件上显示UI通知?_Umbraco_Umbraco6 - Fatal编程技术网

如何在某些Umbraco事件上显示UI通知?

如何在某些Umbraco事件上显示UI通知?,umbraco,umbraco6,Umbraco,Umbraco6,代码是不言自明的: public class TooLateValidator : IApplicationStartupHandler { public TooLateValidator() { ContentService.Saving += ContentService_Saving; } private void ContentService_Saving(IContentService s

代码是不言自明的:

public class TooLateValidator : IApplicationStartupHandler
    {
        public TooLateValidator()
        {
            ContentService.Saving += ContentService_Saving;
        }

        private void ContentService_Saving(IContentService sender, Umbraco.Core.Events.SaveEventArgs<Umbraco.Core.Models.IContent> e)
        {
            if(DateTime.Now.Hour > 21){

                e.Cancel = true;

                //validation message: "it's too late for that"
                // how do I throw this message to UI??

            }
        }
    }
公共类TooLateValidator:IAApplicationStartupHandler
{
公共工具验证程序()
{
ContentService.Saving+=ContentService\u Saving;
}
私有无效内容服务\u保存(IContentService发送方,Umbraco.Core.Events.SaveEventArgs e)
{
如果(DateTime.Now.Hour>21){
e、 取消=真;
//验证消息:“已经太晚了”
//如何将此消息发送到UI??
}
}
}

我正在使用Umbraco 6。

根据评论,这是一个模糊的问题,有许多可能的解决方案。很难看出你到底需要什么,但我会尽力理解的

Umbraco 6的一个突出缺陷是,语音气泡会显示自定义消息,但它们会立即被Umbraco自己的消息覆盖,但现在您可以轻松地做到这一点(感谢我的朋友Ali提供的代码,并在v6.1.6中为我工作)

使用System.Web;
使用System.Web.UI;
使用Umbraco.Core;
使用Umbraco.Core.Events;
使用Umbraco.Core.Models;
使用Umbraco.Core.Services;
使用Umbraco.Web.UI;
使用Umbraco.Web.UI.Pages;
公共类事件:ApplicationEventHandler
{
受保护的覆盖无效应用程序启动(UmbracoApplicationBase umbracoApplication、ApplicationContext ApplicationContext)
{
//事件
ContentService.Created+=Content\u Created;
ContentService.Saving+=内容保存;
}
私有无效内容保存(IContentService发送方,SaveEventArgs e)
{
//1 JavaScript
HttpContext.Current.Response.Write(“警报('Saved!');”;
e、 取消=真;
}
创建的私有无效内容(IContentService发送方,NewEventArgs e)
{
//2翁布拉科演讲泡泡
var clientTool=new ClientTools((第页)HttpContext.Current.CurrentHandler);
ShowSpeechBubble(SpeechBubbleIcon.Success,“警告”,“这么做太晚了!”);
}
}
试试这个

 //validation message: "it's too late for that"
 // how do I throw this message to UI??

 e.Messages.Add(new EventMessage("validation message", "it's too late for that", EventMessageType.Error));

这个问题解决了吗?我遇到了同样的问题…你的意思是你想在CMS中显示一个语音气泡(比如页面发布时)?
 //validation message: "it's too late for that"
 // how do I throw this message to UI??

 e.Messages.Add(new EventMessage("validation message", "it's too late for that", EventMessageType.Error));