zoukankan      html  css  js  c++  java
  • Sharepoint 弹出消息提示框 .

    在event receiver中如何弹出一个类似winform中messagebox.show 的框?

    那我要对用户显示一些错误信息或者提示信息怎么搞?

    1. 

    如果是在ItemAdding或者其他进行时(ing)事件里面,可以使用HttpContext.Current.Response.Write("<script>alert('aaaa');</script>");

    如果是在ItemAdded或者其他结束后(ed)事件里面,那就没招。因为这类事件是异步的,已经获取不到页面的HttpResponse。

    2.

    可以在event reciver 里控制转向错误页面。
    http://www.c-sharpcorner.com/Blogs/4224/sharepoint-2010-event-handler-redirection-to-custom-error-pa.aspx

    properties.Status = SPEventRecieverStatus.CancelWithRedirectUrl;
    Properties.RedirectUrl = “/_layouts/MyBlog/CustomError.aspx"

     

    public override void ItemAdding(SPItemEventProperties properties)

    {

                    base.ItemAdding(properties);

                    string tite = properties.AfterProperties[“title”].ToString();

                    if(tite.Contains(“_”))

                    {

                                    properties.Cancel = true;

                                    properties.Status = SPEventRecieverStatus.CancelWithRedirectUrl;

                                    Properties.RedirectUrl = “/_layouts/MyBlog/CustomError.aspx?errormessage =Inavlid

                                    Title”;

                    }

     

    }

    3.

    Create a application page called customerror.aspx and show the error message from the query string

     

     <asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="Server">    <asp:Label ID="lblError" runat="server" > </asp:Label> </asp:Content>



    4.

    Add the following code in the page load

     

    protected void Page_Load(object sender EventArgs e)

    {

          lblError.Text = Request.Param[“Error”];

    }

    5.

    function openAnswerQandADialog() {
      var options = {
      url: "/_layouts/QandA_PersonalAnswer.aspx",
      600,
      height: 480,
      title: "个人QandA"
      };
      SP.UI.ModalDialog.showModalDialog(options);
      }
    用js调用这个函数吧,这个是sharepoint自己带的函数,使用请在webpart中引用sharepoint命名控件啊。

  • 相关阅读:
    安装python模块时出现:error: Setup script exited with error: command 'gcc' failed with exit status 1
    Thunderbird设置邮件回复时自动签名和邮件引用的位置
    php脚本获取管道的输入数据
    xx is not in the sudoers file
    ubuntu快捷键设置
    (一) solr的安装与配置
    经典地址收集
    VS 2008如何连接TFS 2010
    SQL Server判断对象是否存在(整理中...)
    C++] WAP GPRS 向WWW网站 提交POST GET 数据 实例
  • 原文地址:https://www.cnblogs.com/TNSSTAR/p/3262581.html
Copyright © 2011-2022 走看看