How do I show an error style dialog (i.e. with red error logo and the expand text) from a content editor command?
I've tried to use SheerResponse.ShowError()
. The content editor greys out like it does for regular modals / dialogs, but no error message appears. I'm using Sitecore 8.0 update 3. My code is below:
public class MyCommand: Command
{
public override void Execute(CommandContext context)
{
var nameValueCollection = new NameValueCollection();
if (context.Items.Length == 1)
{
Item item = context.Items[0];
if (item != null
&& item.TemplateID.ToString() == Templates.RedirectSettings.TemplateId)
{
nameValueCollection["id"] = item.ID.ToString();
Sitecore.Context.ClientPage.Start(this, "DoStuff", nameValueCollection);
}
}
}
protected void DoStuff(ClientPipelineArgs args)
{
var itemId = args.Parameters["id"];
if (!args.IsPostBack)
{
SheerResponse.Confirm("Do stuff now?");
args.WaitForPostBack();
}
else if (args.Result == "yes")
{
var everythingOk = //do some stuff and check if successfull..
if (everythingOk)
{
SheerResponse.Alert("Everything worked ok", true, "It's ok");
}
else
{
//something went wrong
SheerResponse.ShowError("My short description", "Detailed description...");
args.WaitForPostBack();
}
}
}