微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

带有SP.UI.Notify.addNotification的本地Cusotm应用程序页面上的SharePoint 2019

如何解决带有SP.UI.Notify.addNotification的本地Cusotm应用程序页面上的SharePoint 2019

我使用SP.UI.Notify.addNotification创建一个自定义应用程序页面,以向用户通知一些信息。我收到了这样的错误消息:是否有人对此有想法。谢谢

未捕获的ReferenceError:未定义SP

我的Application.aspx:

<script src="/_layouts/1033/init.js" type="text/javascript"></script> <script src="/_layouts/15/MicrosoftAjax.js" type="text/javascript"></script> <script src="/_layouts/sp.core.js" type="text/javascript"></script> <script src="/_layouts/sp.runtime.js" type="text/javascript"></script> <script src="/_layouts/sp.js" type="text/javascript"></script>

我的Application.cs:

public static void AddSharePointNotification(System.Web.UI.Page page,string text)
        {
            //build up javascript to inject at the tail end of the page
            System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();

            stringBuilder.AppendLine("<script>");

            //First wait until the SP.js is loaded,otherwise the notification doesn’t work
            //gets an null reference exception
            stringBuilder.AppendLine("SP.soD.executeOrDelayUntilScriptLoaded('sp.js','SP.ClientContext',ShowNotification);");

            stringBuilder.AppendLine("function ShowNotification()");
            stringBuilder.AppendLine("{");
            stringBuilder.AppendLine(string.Format("SP.UI.Notify.addNotification('{0}');",text));
            stringBuilder.AppendLine("}");

            stringBuilder.AppendLine("</script>");

            //add to the page
            //page.Controls.Add(new LiteralControl(stringBuilder.ToString()));
            //System.Web.HttpContext.Current.Response.Write("<script type='text/javascript'>alert('You have no Permission to create project folder')</script>");
            System.Web.HttpContext.Current.Response.Write(stringBuilder.ToString());

        }

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。