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
Hi Guys I got at problem with changing value in my var my code looks like this:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @using Eksponent.CropUp @foreach(var focusBox in Model.Content.AncestorOrSelf(1).Descendants("FokusBoxRight")) { var mediaItem = Umbraco.TypedMedia(focusBox.GetPropertyValue("baggrundsbillede")); <div class="focusBox" style="background: #000 url(@mediaItem.GetPropertyValue("umbracoFile")) no-repeat left top; color: white;"> @focusBox.GetPropertyValue("tekst") @{ var link = "#"; var linkTarget = "_self"; if (focusBox.HasValue("interntLink")) { link = Umbraco.NiceUrl(focusBox.interntLink); } else if(focusBox.HasValue("eksterntLink")) { link = focusBox.eksterntLink; } else if(focusBox.HasValue("mediaLink")) { link = Umbraco.Media(focusBox.mediaLink).Url; } if (focusBox.Where("nytVindue = '1'")) { linkTarget = "_blank"; } } <a href="@link" target="@linkTarget">Læs mere</a> </div> }
The error sounds like: CS1061: 'Umbraco.Core.Models.IPublishedContent' dosent contain a definition of 'interntLink.Can someone please help me :P
Try using:
link = Umbraco.NiceUrl(focusBox.GetPropertyValue("interntLink"));
instead :-)
Already tried that it jyst gives me an other error:contains invalid arguments :P
It could be the NiceUrl that is returning that one.
Try this for debugging:
link = focusBox.GetPropertyValue("interntLink");
Well, have also been there, and it also gives me an error:
The type 'object' can not be converted implicitly to 'string'I'm really confused because - im pretty sure this have worked for me before :/
Try:
link = focusBox.GetPropertyValue("interntLink").ToString();
Ahh okay, but what should i do to the node ID i got then?
Try and check if it insert a node ID, or if it is missing somewhere. If there is one that is empty i could indicate that the HasValue() doesn't work.
Then you maybe could do something like this instead:
if (focusBox.HasValue("interntLink") && focusBox.GetPropertyValue("interntLink") != null && focusBox.GetPropertyValue("interntLink").ToString() != "") { link = Umbraco.NiceUrl(int.Parse(focusBox.GetPropertyValue("interntLink").ToString())); }
NiceUrl parameter must be a int, so it should be like this
link = Umbraco.NiceUrl(focusBox.GetPropertyValue<int>("interntLink"));
Hi Jeavon, worked perfect :DI finally got it to work :DNext time i'll post my Umbraco version as one of the first informations :D
Final code for curious people looks like this:
Umbraco version Umbraco v6.0.5
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage @using Eksponent.CropUp @foreach(var focusBox in Model.Content.AncestorOrSelf(1).Descendants("FokusBoxRight")) { var mediaItem = Umbraco.TypedMedia(focusBox.GetPropertyValue("baggrundsbillede")); <div class="focusBoxRight" style="background: #000 url(@mediaItem.GetPropertyValue("umbracoFile")) no-repeat left top;"> @if(focusBox.HasValue("overskrift")) { <h1>@focusBox.GetPropertyValue("overskrift")</h1> } @focusBox.GetPropertyValue("tekst") @{ var link = "#"; var linkTarget = "_self"; if (focusBox.HasValue("interntLink")) { link = Umbraco.NiceUrl(focusBox.GetPropertyValue<int>("interntLink")); } else if(focusBox.HasValue("eksterntLink")) { link = focusBox.GetPropertyValue("eksterntLink").ToString(); } else if(focusBox.HasValue("mediaLink")) { link = Umbraco.Media(focusBox.GetPropertyValue("mediaLink")).Url; } if (focusBox.Where("nytVindue = True")) { linkTarget = "_blank"; } } <a class="readMore" href="@link" target="@linkTarget"><span><img src="/images/rld/btn_arrow_white.png" /></span>Læs mere</a> </div> }
Good stuff and yes always a good idea to start forum posts including your Umbraco version :)
I would also use the type specifier here:
else if(focusBox.HasValue("eksterntLink")) { link = focusBox.GetPropertyValue<string>("eksterntLink"); }
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
PartialView: Change variable value
Hi Guys
I got at problem with changing value in my var my code looks like this:
The error sounds like: CS1061: 'Umbraco.Core.Models.IPublishedContent' dosent contain a definition of 'interntLink.
Can someone please help me :P
Try using:
instead :-)
Already tried that it jyst gives me an other error:
contains invalid arguments :P
It could be the NiceUrl that is returning that one.
Try this for debugging:
Well, have also been there, and it also gives me an error:
The type 'object' can not be converted implicitly to 'string'
I'm really confused because - im pretty sure this have worked for me before :/
Try:
Ahh okay, but what should i do to the node ID i got then?
Try and check if it insert a node ID, or if it is missing somewhere. If there is one that is empty i could indicate that the HasValue() doesn't work.
Then you maybe could do something like this instead:
NiceUrl parameter must be a int, so it should be like this
Hi Jeavon, worked perfect :D
I finally got it to work :D
Next time i'll post my Umbraco version as one of the first informations :D
Final code for curious people looks like this:
Umbraco version Umbraco v6.0.5
Good stuff and yes always a good idea to start forum posts including your Umbraco version :)
I would also use the type specifier here:
is working on a reply...