Hello everyone,
the question was already asked here:
i actually want to do exactly the same, convert an existing string property in a page to XhtmlString. So i want to use MigrationSteps.
Unfortunately there is nowhere an example on how to do it. This is the documentation:
It lacks sample code(apart from renaming a property which you find everywhere in the internet) that shows how to convert the type.
As a workaround i have tried to do it with another property even if that pollutes my class and needs a lot of work to fix it everywhere:
[CultureSpecific]
[Display(
Name = "Title",
Description = "Article title",
Order = 999)]
[ScaffoldColumn(false)]
[Editable(false)]
[Obsolete("Replaced with the XhtmlString property ArticleTitle")]
public virtual string Title { get; set; }
[CultureSpecific]
[Display(
Name = "Title",
Description = "Article title",
Order = 220)]
[UIHint(UIHint.Textarea)]
public virtual XhtmlString ArticleTitle
{
get
{
XhtmlString articleTitle = this.GetPropertyValue(page => page.ArticleTitle);
return articleTitle ?? new XhtmlString(this.GetPropertyValue(page => page.Title));
}
set { this.SetPropertyValue(page => page.ArticleTitle, value); }
}
One issue i have with this is that the old Title is correctly returned but it's not visible in CMS. So the CMS-Editor thinks it is empty. How to fix that?
Thanks in advance,
Tim