The if statement if (callToAction.CallToActionIcon != null)
{ works perfectly, it gives me the image, the text and the link and so I expected to be able to get the else to work just as easy. I was wrong.
As you can see, the first statement works, I have the image, the text and the lin, but the component above that just outputs RJP.MultiUrlPicker.Models.Link.
I've tried a number of different thinks and I either get a # as the link, an error, or nothing at all!
I really hope someone can help. I'm open to suggestions on how to make the code better too.
@{
var link = callToAction.GetPropertyValue<RJP.MultiUrlPicker.Models.Link>("Link");
<a href="@link.Url">@link.Name</a>
}
A property value converter is converting your value to the model RJP.MultiUrlPicker.Models.Link and by just calling @callToAction.GetPropertyValue("Link") razor is calling the .ToString() method on it. So that is why you are seeing the class name :-)
RJP.MultiUrlPicker issues
Hi everyone
I'm having strange issue with trying to get the URL from a RJP.MultiUrlPicker.
My code looks like this:
I'm using Models Builder and Nested Content.
The if statement
if (callToAction.CallToActionIcon != null) {
works perfectly, it gives me the image, the text and the link and so I expected to be able to get theelse
to work just as easy. I was wrong.As you can see, the first statement works, I have the image, the text and the lin, but the component above that just outputs RJP.MultiUrlPicker.Models.Link.
I've tried a number of different thinks and I either get a # as the link, an error, or nothing at all!
I really hope someone can help. I'm open to suggestions on how to make the code better too.
Cheers.
Owain
Hey Owain :-)
Try replacing this:
with:
A property value converter is converting your value to the model RJP.MultiUrlPicker.Models.Link and by just calling @callToAction.GetPropertyValue("Link") razor is calling the .ToString() method on it. So that is why you are seeing the class name :-)
edit don't forget null checks :-)
Cheers
Nik
Cheers for the speedy reply Nik! Problem solved!
h5yr
O.
is working on a reply...