item.GetProperty(“bodyText的”)值一把umbraco
问题描述:
你好,我已经受够了从我一把umbraco博客页面收集的对象specificly裁剪下来item.GetProperty(“bodyText的”)值一把umbraco
@foreach (var item in Model.Content.Children.Where("visible==true"))
{
var BodyTextToCrop = item.GetProperty("bodytext").Value.ToString();
<a href="@item.Url">@item.Name</a><br />
@Umbraco.Truncate(BodyTextToCrop, 2, true)
}
答
你的声明更改为以下问题:
@foreach (var item in Model.Content.Children.Where(x => x.IsVisible()))
{
var BodyTextToCrop = item.GetProperty("bodytext").Value.ToString();
<a href="@item.Url">@item.Name</a><br />
@Umbraco.Truncate(BodyTextToCrop, 2, true)
}
看起来你的where子句使用的是类型的动态访问,Model.Content可以在你的情况下强类型化。
在 片段看一看在页面上:
//dynamic access
@CurrentPage.Children.Where("Visible")
//strongly typed access
@Model.Content.Children.Where(x => x.IsVisible())
问题是什么?你尝试过调试吗? –