在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",
  width: 600,
  height: 480,
  title: "个人QandA"
  };
  SP.UI.ModalDialog.showModalDialog(options);
  }
用js调用这个函数吧,这个是sharepoint自己带的函数,使用请在webpart中引用sharepoint命名控件啊。

最新文章

  1. vim修改文字编码
  2. 巴特沃斯(Butterworth)滤波器 (2) - 双线性变换
  3. 1-11 ICMP协议
  4. ASP.NET MVC5 网站开发实践
  5. IMapDocument interface
  6. Struts – Multiple configuration files example
  7. bzoj2797
  8. iOS开发之监测网络状态
  9. windows10 预览版 中英文官方下载地址+激活密钥+网盘分享
  10. nginx+keepalived实现nginx双主高可用的负载均衡
  11. codevs 3223 素数密度
  12. 基于visual Studio2013解决C语言竞赛题之1065二维排序
  13. 慎用kill -9,kill -15的作用
  14. 集美大学网络1413第十二次作业成绩(个人作业3) -- Alpha阶段个人总结
  15. mysql加速source导入数据
  16. YOLO系列:YOLO v1深度解析
  17. ogg12.2中的新参数 AllowOutputDir
  18. 为什么要使用mybaits
  19. 搭建中小规模集群之rsync数据同步备份
  20. Actor模式初步入门

热门文章

  1. html音视频标签
  2. 关于System.currentTimeMillis()
  3. BuildingAndRunningUAFServerUsingMaven
  4. scala集合和高级函数操作
  5. CentOS6.3添加nginx系统服务详细说明
  6. CodeForces 705B Spider Man
  7. 小程序--改变子级别页面导航栏信息 / navigationBarTitleText
  8. CSS3秘笈复习:第九章&amp;第十章
  9. Maxmum subsequence sum problem
  10. JVM基础02-class文件