Web developers wiki ASP.NET Sitecore Sharepoint Kentico by Evident Interactive

Sitecore confirm Message with custom ribbon button

Modified: 2013/01/04 17:35 by Vincevanm - Categorized as: Sitecore
Let's consider the following scenario:

We want to create a custom Ribbon (top menu) button with an action that deletes certain items or users. Before this action commences we want the CMS user to confirm that this is what he/she want's to invoke and give an option to cancel. Check out the following example to achieve this:

Example:
Image

Code:


public class RemoveUsersFromAudience : Sitecore.Shell.Framework.Commands.Command
	{
		public override void Execute(Sitecore.Shell.Framework.Commands.CommandContext context)
		{
			if (context.Items.Length == 1)
			{
				NameValueCollection parameters = new NameValueCollection();
				parameters"items" = SerializeItems(context.Items);
				Context.ClientPage.Start(this, "Run", parameters);
			}
		}


protected void Run(ClientPipelineArgs args)
{


if (!args.IsPostBack)
{
	Sitecore.Web.UI.Sheer.SheerResponse.Confirm("Delete all users from selected audience?");
					args.WaitForPostBack();
}
else if(args.Result == "yes")
{

//Get the current context item (if this is a contextual ribbon) and start the action
Item item = DeserializeItems(args.Parameters"items")0;

}


}

}

 © Evident Interactive BV