Sitecore - 向FormDialog添加按钮

时间:2014-07-09 08:40:10

标签: sitecore sitecore6 sitecore7

是否可以将自定义按钮添加到除OkButton和CancelButton之外的Sitecore FormDialog,例如而不是这个

<FormDialog Icon="cool.png" Header="A really cool header" Text="Link or un-link items" OKButton="Link" CancelButton="Close">

但更像是这样的

<FormDialog Icon="cool.png" Header="A really cool header" Text="Link or un-link items" OKButton="Link" UnLinkButton="UnLink" CancelButton="Close">

1 个答案:

答案 0 :(得分:1)

我不认为可以通过传入FormDialog元素上的属性来添加另一个按钮而不修改原始的FormDialog.xml

但是DialogForm控件中定义了占位符元素(在 / sitecore / shell / Controls / Dialogs 中)

<def:Placeholder name="Buttons"/>

在自定义应用程序的xml中,您可以向此占位符添加控件:

<control xmlns:def="Definition" xmlns="http://schemas.sitecore.net/Visual-Studio-Intellisense">
  <MyCustomForm>
    <FormDialog Icon="cool.png" Header="A really cool header" Text="Link or un-link items" OKButton="Close" CancelButton="false">

      <CodeBeside Type="MyCustomCode.Dialogs.MyCustomForm, MyCustomCode"/>

      <GridPanel Columns="2" CellPadding="4" Width="100%" Height="100%">
          <!-- Panel code here -->
      </GridPanel>

      <Border def:placeholder="Buttons" runat="server" style="float:right;">
        <Button Header="Link" runat="server" Type="button" Click="Link_Click" />
        <Button Header="Unlink" runat="server" Type="button" Click="Unlink_Click" onclick="return confirm('Are you sure you want to unlink?');" />      
      </Border>

    </FormDialog>
  </MyCustomForm>
</control>

注意您要传入隐藏取消按钮的CancelButton="false"并将确定按钮文本设置为“关闭”。在后面的代码中处理您的链接/取消链接服务器操作。我将按钮组设置为float:right,然后将它们放在“关闭”按钮旁边。

Form with custom buttons