扩展Sitecore并使用纯粹的UI问题

时间:2013-02-04 14:05:48

标签: c# sitecore

如何按顺序显示两个Sheer UI对话框?我想要做的是在Input对话框成功完成后显示Confirm对话框,然后显示Input对话框。

目前,我只使用Command.Run()方法:

        if (!args.IsPostBack) {
               SheerResponse.Input(
                    "Enter the new event date (ISO format YYYY-MM-DD):",
                    "",
                    @"\d{4}\-\d{2}\-\d{2}",
                    "'$Input' is not a valid date.",
                    100
                );

                args.WaitForPostBack();
        } else {
            ...do stuff...
        }

2 个答案:

答案 0 :(得分:2)

在示例代码中,我们首先显示一个对话框而不是确认对话框。希望这个帮助

    public void Run(ClientPipelineArgs args)
    {
        try
        {
            if (!args.IsPostBack)
            {
                Context.ClientPage.ClientResponse.ShowModalDialog(url.ToString(), true);
                args.WaitForPostBack();
            }
            else if (args.HasResult)
            {
                // Small job confirmation. User decide 'no'
                if (args.Result == "no")
                {
                    return;
                }

                if(args.Result == "result")
                {
                  SheerResponse.Confirm("message");
                  args.WaitForPostBack();
                }
            }
        }
        catch (EndpointNotFoundException ex)
        {
    //something 
        }
    }

答案 1 :(得分:0)

似乎我需要为我要调用的命令获取Command的实例,然后在此调用Execute(),例如:

    private void CreateEvent(ClientPipelineArgs args)
    {
        var org_lang = Language.Current;
        Language lang = Language.Parse("en-gb");
        Language.Current = lang;
        Database db = Configuration.Factory.GetDatabase(args.Parameters["database"]);
        Item parent = db.GetItem(args.Parameters["id"], lang);

        try {
            // Create command context
            CommandContext command_context = new CommandContext(parent);

            // Get command
            Command command = CommandManager.GetCommand("fairsite:createcampaign");

            // Execute command
            command.Execute(command_context);
        } finally {
            Language.Current = org_lang;
        }
    }