Вы можете сделать что-то вроде этого:
public override void ItemDeleting(SPItemEventProperties properties)
{
string updateID = Convert.ToString(properties.ListItem["ID"], CultureInfo.InvariantCulture);
string itemUID = tmpItem.UniqueId.ToString();
string urlProcessing = string.Format(CultureInfo.InvariantCulture, Constants.StringRedirect, web.Url, Constants.PersonRecord, "Processing.aspx", itemUID, updateID, modifyTime);
properties.Status = SPEventReceiverStatus.CancelNoError;
SPUtility.Redirect(urlProcessing, SPRedirectFlags.Static, this.currentContext);
}
Processing.aspx
будет содержать пользовательскую веб-часть MessageBox, которая удалит элемент или не зависит от ответа. Он будет читать идентификатор из строки запроса Url. Вот фрагмент:
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
/// <summary>
/// This class contains operations to check if a username is duplicated or not
/// </summary>
[Guid("ddeaa4a4-6d63-4fc8-9a17-8874db582388")]
[SecurityPermission(SecurityAction.LinkDemand, Unrestricted = true)]
[SecurityPermission(SecurityAction.InheritanceDemand, Unrestricted = true)]
[CLSCompliant(false)]
public class ConfirmWebpart : Microsoft.SharePoint.WebPartPages.WebPart
{
/// <summary>
/// Duplicated username
/// </summary>
private string userName;
/// <summary>
/// UNID of a item
/// </summary>
private string itemID;
/// <summary>
/// ID of updating item
/// </summary>
private string updateID;
/// <summary>
/// Last edit time
/// </summary>
private string lastEdit;
/// <summary>
/// To check error in the application.
/// </summary>
private bool error;
/// <summary>
/// Current context
/// </summary>
private HttpContext currentContext;
/// <summary>
/// Initializes a new instance of the ConfirmWebpart class.
/// </summary>
public ConfirmWebpart()
{
this.currentContext = HttpContext.Current;
this.ExportMode = WebPartExportMode.All;
}
/// <summary>
/// Ensures that the CreateChildControls() is called before events.
/// Use CreateChildControls() to create your controls.
/// </summary>
/// <param name="e">e parameter</param>
[SuppressMessage("Microsoft.Security", "CA2109:ReviewVisibleEventHandlers", Justification = "This is to catch all possible exceptions and to prevent exceptions to bubble up on screen.")]
protected override void OnLoad(EventArgs e)
{
if (!this.error)
{
try
{
base.OnLoad(e);
this.EnsureChildControls();
}
catch (Exception ex)
{
this.HandleException(ex);
throw;
}
}
}
/// <summary>
/// Create all your controls here for rendering.
/// Try to avoid using the RenderWebPart() method.
/// </summary>
protected override void CreateChildControls()
{
if (!this.error)
{
try
{
base.CreateChildControls();
this.GetQueryStringValues();
this.RenderContents();
}
catch (Exception ex)
{
this.HandleException(ex);
throw;
}
}
}
/// <summary>
/// Clear all child controls and add an error message for display.
/// </summary>
/// <param name="ex">ex parameter</param>
protected void HandleException(Exception ex)
{
this.error = true;
this.Controls.Clear();
this.Controls.Add(new LiteralControl(ex.Message));
}
/// <summary>
/// Get all querystring value and assign to private members
/// </summary>
protected void GetQueryStringValues()
{
this.itemID = Page.Request.QueryString[Constants.ItemD];
this.updateID = Page.Request.QueryString[Constants.Update];
this.lastEdit = Page.Request.QueryString[Constants.LastEdit];
}
/// <summary>
/// Render UI form
/// </summary>
protected void RenderContents()
{
this.GetDuplicatedUserName();
this.Controls.Add(new LiteralControl("<table cellpadding=\"0\" cellspacing=\"0\"><tr style=\"height:50px\"><td style=\"width:50px\"></td><td colspan=\"3\"></td></tr><tr style=\"font-size: medium;color: #3366FF;height:40px\"><td></td><td colspan=\"3\">"));
this.Controls.Add(new LiteralControl(string.Format(CultureInfo.CurrentCulture, Constants.ConfirmMessage, this.userName)));
this.Controls.Add(new LiteralControl("</tr><tr><td></td><td colspan=\"3\"></td></tr><tr><td style=\"color: #3366FF\"></td><td colspan=\"3\" style=\"color: #3366FF\">"));
this.Controls.Add(new LiteralControl(Constants.YesAction));
this.Controls.Add(new LiteralControl("</tr><tr><td style=\"color: #3366FF\"></td><td colspan=\"3\" style=\"color: #3366FF\">"));
this.Controls.Add(new LiteralControl(Constants.NoAction));
this.Controls.Add(new LiteralControl("</td></tr><tr><td></td><td colspan=\"3\" style=\"height:20px\"></td></tr><tr><td style=\"width:100px\"></td><td style=\"width:100px\"></td><td>"));
//// Add Yess button
Button btnYes = new Button();
btnYes.Text = Constants.YesButtonLabel;
btnYes.Width = new Unit(70);
btnYes.Click += new EventHandler(this.BtnYesClick);
this.Controls.Add(btnYes);
this.Controls.Add(new LiteralControl("</td><td>"));
//// Add No button
Button btnNo = new Button();
btnNo.Text = Constants.NoButtonLabel;
btnNo.Click += new EventHandler(this.BtnNoClick);
btnNo.Width = new Unit(70);
this.Controls.Add(btnNo);
this.Controls.Add(new LiteralControl("</td></tr></table>"));
}
/// <summary>
/// This method is used to handle the click event of Yes button
/// </summary>
/// <param name="sender">sender parameter</param>
/// <param name="e">argument parameter</param>
private void BtnYesClick(object sender, EventArgs e)
{
//Delete the item
}
/// <summary>
/// This method is used to handle the click event of No button
/// </summary>
/// <param name="sender">sender parameter</param>
/// <param name="e">argument parameter</param>
private void BtnNoClick(object sender, EventArgs e)
{
// Redirect to the default view of People list
string defaultView = string.Format(CultureInfo.InvariantCulture, Constants.WebRedirectUrl, SPContext.Current.Web.Url, Constants.ListName);
SPUtility.Redirect(defaultView, SPRedirectFlags.Trusted, this.currentContext);
}
}