带有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 (将#修改为@)