Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I have a node with a content picker. I need to get the url of the picked node in a view.
var myLink = @Model.GetPropertyValue("link");
Gives me the ID of the node
var myLink = @Model.GetPropertyValue("link").Url;
throws an error "Cannot assign method group to an implicitly-typed local variable", the same happens when using
var myLink = @Model.GetPropertyValue("link").NiceUrl;
What's the right way to do it?
Hi Claus,
I would suggest this:
var myLink = Umbraco.NiceUrl(Model.GetPropertyValue("link"));
Jeavon
That returns an error
"The best overloaded method match for 'Umbraco.Web.UmbracoHelper.NiceUrl(int)' has some invalid arguments"
Ah ok,
var myLink = Umbraco.NiceUrl(Model.GetPropertyValue<int>("link"));
Im going nuts...
You cannot have those "@" in the code blocks e.g
var myTeaser = @Model.
has to be
var myTeaser = Model.
OK :)
Tjats weird, 'cause it worked fine, until i wanted the url...
I ended up with this,, and it works. Thanks for the lesson ;)
In some situations it will work, but it's better just to never do it. In Razor v1, you could do it a lot but Razor v2 is not so forgiving.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
Get Node url from id
I have a node with a content picker. I need to get the url of the picked node in a view.
Gives me the ID of the node
throws an error "Cannot assign method group to an implicitly-typed local variable", the same happens when using
What's the right way to do it?
Hi Claus,
I would suggest this:
Jeavon
That returns an error
"The best overloaded method match for 'Umbraco.Web.UmbracoHelper.NiceUrl(int)' has some invalid arguments"
Ah ok,
Im going nuts...
You cannot have those "@" in the code blocks e.g
has to be
OK :)
Tjats weird, 'cause it worked fine, until i wanted the url...
I ended up with this,, and it works. Thanks for the lesson ;)
In some situations it will work, but it's better just to never do it. In Razor v1, you could do it a lot but Razor v2 is not so forgiving.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.