我有一个具有这两个属性的Block Type。
[CultureSpecific]
[Display(
Name = "Display PDF Button", GroupName = TabNames.PDFCustomisation, Order = 0)]
public virtual bool DisplayPdfButton { get; set; }
[CultureSpecific]
[Required]
[Display(
Name = "Download Pdf Text", GroupName = TabNames.PDFCustomisation, Order = 1)]
public virtual string DownloadPdfText { get; set; }
如果用户将DisplayPdfButton设置为True,我只需要DownloadPdfText。 - 这可以在Episerver中做到吗?
答案 0 :(得分:2)
另一种方法是为自定义验证实现事件处理程序,例如SavingContent
或PublishingContent
事件。
这样,您可以查看正在保存和/或发布的内容类型,并决定是否验证。
事件处理程序参数具有可以设置为停止保存/发布的属性,还可以指定原因(查看CancelAction
和CancelReason
属性)。
答案 1 :(得分:1)
这样做的一种方法是实现自己的验证属性。如果选中DisplayPdfButton并且DownloadPdfText为空,则可以将其验证为false。请在此处阅读有关如何执行此操作的信息:https://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/9/Content/Properties/Property-types/Writing-custom-attributes/