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
Hello,
We are trying to switch from 4.7.0 to 4.7.2 and after changing all our existing razor scripts does not work any more.
As an example:
<ul id="newsticker">@{ var news = Model.NewsTickerItems; foreach(dynamic item in news) { if(!string.IsNullOrEmpty(@item.Link)) { <li>++++ <a href="@Model.NodeById(item.Link).NiceUrl">@item.Text</a> ++++</li> } else { <li>++++ @item.Text ++++</li> } }}</ul>
throws an error:
Error loading Razor Script HomeNewsTicker.cshtmlThe best overloaded method match for 'string.IsNullOrEmpty(string)' has some invalid arguments
after changing if(!string.IsNullOrEmpty(@item.Link)) to if(!string.IsNullOrEmpty(@item.Link.ToString())) i am getting the following error:
Error loading Razor Script HomeNewsTicker.cshtmlCannot instantiate a DynamicNode without an id
Is there someone who can help me by rewriting the code so it will also work under 4.7.2?
The XML looks like:
<newsTickerItems>
<data>
<item id="1">
<Text propertyid="1">Test1</Text>
<Link propertyid="2" />
</item>
<item id="2">
<Text propertyid="1">Test2</Text>
<item id="3">
<Text propertyid="1">Test3</Text>
<Link propertyid="2">1439</Link>
</data>
</newsTickerItems>
i was able to solve it by using
@item.Link.InnerText instead of @item.Link and
@item.Text.InnerText instead of @item.Text
Can someone explain this? Why this has been changed from version 4.7.0 to 4.7.2
Will this change also if I am upgrading to version 4.9?
Can somebody please help?
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Problems after changing from 4.7.0 to 4.7.2
Hello,
We are trying to switch from 4.7.0 to 4.7.2 and after changing all our existing razor scripts does not work any more.
As an example:
<ul id="newsticker">
@{
var news = Model.NewsTickerItems;
foreach(dynamic item in news)
{
if(!string.IsNullOrEmpty(@item.Link))
{
<li>++++ <a href="@Model.NodeById(item.Link).NiceUrl">@item.Text</a> ++++</li>
} else {
<li>++++ @item.Text ++++</li>
}
}
}
</ul>
throws an error:
Error loading Razor Script HomeNewsTicker.cshtml
The best overloaded method match for 'string.IsNullOrEmpty(string)' has some invalid arguments
after changing if(!string.IsNullOrEmpty(@item.Link)) to if(!string.IsNullOrEmpty(@item.Link.ToString())) i am getting the following error:
Error loading Razor Script HomeNewsTicker.cshtml
Cannot instantiate a DynamicNode without an id
Is there someone who can help me by rewriting the code so it will also work under 4.7.2?
The XML looks like:
<newsTickerItems>
<data>
<item id="1">
<Text propertyid="1">Test1</Text>
<Link propertyid="2" />
</item>
<item id="2">
<Text propertyid="1">Test2</Text>
<Link propertyid="2" />
</item>
<item id="3">
<Text propertyid="1">Test3</Text>
<Link propertyid="2">1439</Link>
</item>
</data>
</newsTickerItems>
i was able to solve it by using
@item.Link.InnerText instead of @item.Link and
@item.Text.InnerText instead of @item.Text
Can someone explain this? Why this has been changed from version 4.7.0 to 4.7.2
Will this change also if I am upgrading to version 4.9?
Can somebody please help?
is working on a reply...