开发者

How to use .trim().length in .cshtml page

I have written following condition in .cshtml page but it is not working

@if (row.item.FullName.Trim().length <= 0)
    开发者_如何学JAVA        {
                @Html.ActionLink("Create", "Create", "UsersInfo")
            }
            else
            {
                <a href='@Url.Action("Edit", "UsersInfo", new { id = row.item.UserId }))'>Contact</a>
            }

My requirement is if FullName contains empty then link visible for Create else Edit. It is giving me following

Error:

System.NullReferenceException: Object reference not set to an instance of an object.

if i use @if (row.item.FullName == "") then it will display following screen

<img src='http://www.codeproject.com/script/Membership/Uploads/5038017/screen.png'/>


Try String.IsNullOrEmpty(row.item.FullName).


Try this:

@if (String.IsNullOrEmpty(row.item.FullName))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜