如何使用Sitecore ShowControlPopup与用户进行对话交互?

时间:2011-07-29 03:11:41

标签: sitecore sitecore6

我根据数据定义手册中的内容创建了一些简单的命令,其中用户交互是右键单击项目 - >插入 - > MyCommand后跟一个简单的对话框,上面写着“你真的想要这样做吗”。那很棒。

现在我想要一个允许我在对话框中与用户进行更多交互的命令。我需要添加几个单选按钮列表,以便用户可以选择选项,然后选择一个按钮来运行命令。我想我需要使用ShowControlPopup。我已经创建了一个控件(ascx)来定义弹出窗口的样子(并且发布了一个测试版本,以确定它是Sitecore中的基本控件)。但是,我不确定ShowControlPopup的确切参数是什么。

第一个被称为“Id” - 我在这里放了什么?使用弹出控件的项的id?

第二个参数叫做“where” - 我猜这是弹出窗口的URL。是否需要在此处存在内容项,或者它只是一个虚拟URL?

第三个参数叫做“controlId” - 我在这里放了什么ID?我已经尝试了我的控件的id来定义弹出窗口,但是我得到一个错误,说无法找到控件。

当用户在对话框中选择了他们的选项并单击“确定”处理事件的内容时?弹出控件的代码隐藏中的命令类的Run方法或事件处理程序?

到目前为止,这是我的代码。如果尝试创建控件时失败,并且出现无法找到提供了id的项目的错误。我刚刚猜测了弹出控件想要了解的内容。

protected void Run(Sitecore.Web.UI.Sheer.ClientPipelineArgs args)
{
 if (args.IsPostBack)
 {
  if (args.HasResult)
  { // normally code here would run when the dialog box is completed by the user.  Is that so in this case?

  }
 }
 else
 {
  Sitecore.Context.ClientPage.ClientResponse.ShowControlPopup("F3684C4C-D9EF-4796-A471-5B05553119B6",
                 "http://mysite/dummy.aspx",
                 "B8D503D0-AEBE-43AE-B924-C3849F03E90D");

  args.WaitForPostBack();
 }
}

干杯,

詹姆斯。

Sitecore 6.2 rev 091012 / Win7 32bit / IIS7 / SQLExpress 2008(仅限本地开发)

1 个答案:

答案 0 :(得分:4)

仅为了记录,Sitecore支持回来了一些答案

1)“Id”是触发弹出窗口的项目的ID

2)“Where”是相对于“Id”的位置。例如,上方,下方,右下方

3)“controlId”是弹出窗口

的项目的ID

使用ShowPopupControl的Sitecore示例是主菜单和上下文菜单。

此外,SheerUI仍未记录,我被告知只需在Sitecore代码库中查找示例。很高兴我们可以查看Sitecore代码,但是一个小方向会很棒。即使doco简单地说“为了使用ShowPopupControl,UI示例x可以在dll z中的y类中找到”。

命令的生命&弹出窗口可以使用弹出窗口中的代码隐藏或命令本身来完成。这取决于最终的args.WaitForPostBack(),它也可以是'args.WaitForPostBack(true)or 'args.WaitForPostBack(false)

最后我选择了ShowModalDialog(),因为这实际上是我想要的,而不是用户可以点击的弹出窗口。

所以我的代码最终看起来像这样

protected void Run(Sitecore.Web.UI.Sheer.ClientPipelineArgs args)
{
    if (args.IsPostBack)
    {
        ;// we never come here becuase we have set waitforpostback to false.  all processing is handled by the popup control
    }
    else
    {
        Sitecore.Text.UrlString popUpUrl = new Sitecore.Text.UrlString("/sitecore/content/MYSITE/MyControlPageItem.aspx");
        popUpUrl.Append("id", args.Parameters["id"]);
        popUpUrl.Append("database", args.Parameters["database"]);
        popUpUrl.Append("language", args.Parameters["language"]);
        Sitecore.Context.ClientPage.ClientResponse.ShowModalDialog(popUpUrl.ToString(),"400", "600", "", true);

        args.WaitForPostBack(false);    // if this is true this command will wait for the modal dialog created above to close
                                        // at which time the Run method will check for postback & args
    }
}