我已經寫了在以下頁面.cshtml條件,但它不工作如何使用.trim()。長度
@if (row.item.FullName.Trim().length <= 0)
{
@Html.ActionLink("Create", "Create", "UsersInfo")
}
else
{
<a href='@Url.Action("Edit", "UsersInfo", new { id = row.item.UserId }))'>Contact</a>
}
我的要求是,如果FullName
包含空然後創建其他鏈接可見編輯。這是給我下面
錯誤:
System.NullReferenceException: Object reference not set to an instance of an object.
如果我使用@if (row.item.FullName == "")
然後它會顯示以下屏幕
<img src='http://www.codeproject.com/script/Membership/Uploads/5038017/screen.png'/>
優秀的解決方案! – imdadhusen