1
我製作了帶有ImageUrl屬性和Description屬性的ImageBlock。 ImageUrl是必需的。EPiserver 7在可選塊內需要屬性
[ContentType(
DisplayName = "Image",
Description = "Image with description and caption",
GUID = "387A029C-F193-403C-89C9-375A2A6BF028",
AvailableInEditMode = false)]
public class ImageBlock : BaseBlock
{
[Required]
[UIHint(UIHint.Image)]
[Display(
Name = "Image Url",
Description = "",
GroupName = SystemTabNames.Content,
Order = 10)]
public virtual Url ImageUrl { get; set; }
[Display(
Name = "Image Description",
Description = "A description of the image",
GroupName = SystemTabNames.Content,
Order = 20)]
public virtual string Description { get; set; }
}
我的ArticlePage使用ImageBlock作爲它的Image屬性,但它不需要在文章中有圖像。但是,如果編輯選擇了圖像,則應該需要url。
[Display(
Name = "Image",
Description = "",
GroupName = SystemTabNames.Content,
Order = 20)]
public virtual ImageBlock Image { get; set; }
但是,當我創建一個ArticlePage的新實例時,系統會提示您提供EPiServer聲稱所需的ImageUrl。我錯過了什麼嗎?