加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc-3 – 在if语句中的Asp.net MVC 3 Razor代码问题

发布时间:2020-12-16 06:44:35 所属栏目:asp.Net 来源:网络整理
导读:我有以下asp.net mvc 3 razor代码,其中“item”是我的模型, a @if (item.Selected) { class="youarehere" } href="@item.Href" title="@item.Title"@item.Description/a 此代码抛出以下错误, CS1513: } expected 这是指向 class="youarehere" 部分代码,但我
我有以下asp.net mvc 3 razor代码,其中“item”是我的模型,

<a @if (item.Selected) { class="youarehere" } href="@item.Href" title="@item.Title">@item.Description</a>

此代码抛出以下错误,

CS1513: } expected

这是指向

class="youarehere"

部分代码,但我无法弄清楚原因.有人可以帮忙指出如何解决它吗?谢谢.

解决方法

试试这个:

<a @if (item.Selected) { @:class="youarehere" } 
 href="@item.Href" 
 title="@item.Title">
 @item.Description
</a>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读