How does one pop up a box similar to MessageBox. Show in winform in event aggreger?
| So how can I display some error messages or prompt messages to users? |
1.
Httpcontext can be used for itemadding or other ongoing (ing) events. current. response. write ("<SCRIPT> alert ('aaa'); </SCRIPT> ");
If it is in itemadded or another post-end (ed) event, no action is taken. Because such events are asynchronous, The httpresponse of the page cannot be obtained.
2.
You can control the redirection error page in 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: "personal qanda"
};
Sp. UI. modaldialog. showmodaldialog (options );
}
Use js to call this function. This is a function provided by Sharepoint. Please reference the SharePoint naming control in webpart.