MultiUrlPickerState.Deserialize in v6.0 not working as it did in 5.5 (and a solution)
I've just upgraded an Umbraco 6.1.6 (MVC) site from uComponents v5.5 to 6.0 - I did this using a package but I also used Nuget too (as I had a class library that referenced uComponents). The upgrade went fine. I also republished the entire site, too.
However, I noticed that everywhere I'd used the MulitUrl picker that I was getting either no links being shown or null reference exceptions. I was using the MultiUrlPickerState.Deserialize method to deserialise the links into a collection of UrlPickerState objects. Example code was something like:
var links = MultiUrlPickerState.Deserialize(item.GetPropertyValue<string>("links")); @if (links != null && links.Items.Any()) { <div class="direction-links"> @foreach (var link in links.Items) { string title = link.Title; // EXCEPTION! if (link.Mode == uComponents.DataTypes.UrlPicker.UrlPickerMode.URL) { title += " website"; } else if (link.Mode == uComponents.DataTypes.UrlPicker.UrlPickerMode.Media) { title += " (file)"; }
if (link.NewWindow) { title += " [opens in new window]"; }
Thanks Dan. Glad that you got a solution. Weird that it broke with the upgrade. As far as I recall there haven't been any amends to Multi-UrlPicker between v5.x and v6.x.
Yeah, what's weird is that in some places the old cold still works and in some places it doesn't! Doesn't make much sense. I suspect it's more of an Umbraco issue than uComponents, as I've seen similar weirdness with other datatypes in the past. But hopefully if anyone encounters this it might help :)
I'm currently having the same issue, when using the deserialize method. It only returns one record and isn't a valid MutiUrlPickerState. Sticking with v5 for now I guess.
MultiUrlPickerState.Deserialize in v6.0 not working as it did in 5.5 (and a solution)
I've just upgraded an Umbraco 6.1.6 (MVC) site from uComponents v5.5 to 6.0 - I did this using a package but I also used Nuget too (as I had a class library that referenced uComponents). The upgrade went fine. I also republished the entire site, too.
However, I noticed that everywhere I'd used the MulitUrl picker that I was getting either no links being shown or null reference exceptions. I was using the MultiUrlPickerState.Deserialize method to deserialise the links into a collection of UrlPickerState objects. Example code was something like:
now throws an exception.
However, I have found a solution - instead of using the Deserialise method I just changed my initial code to:
This works perfectly (and is also more intuitive!).
Thanks Dan. Glad that you got a solution. Weird that it broke with the upgrade. As far as I recall there haven't been any amends to Multi-UrlPicker between v5.x and v6.x.
Yeah, what's weird is that in some places the old cold still works and in some places it doesn't! Doesn't make much sense. I suspect it's more of an Umbraco issue than uComponents, as I've seen similar weirdness with other datatypes in the past. But hopefully if anyone encounters this it might help :)
I'm currently having the same issue, when using the deserialize method. It only returns one record and isn't a valid MutiUrlPickerState. Sticking with v5 for now I guess.
is working on a reply...