异常信息:Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions

解决办法:

由以下代码:
@foreach (var item in Model)
{
@Html.DisplayFor(m => !item.IsIdle, "BoolIcon")
}
改为: @foreach (var item in Model)
{
var active = !item.IsIdle;
@Html.DisplayFor(m => active , "BoolIcon")
}

或者

由以下代码:

<div class="controls" style="width:20%">
@{ int index = @Model.chapter_index + 1;}
@Html.TextBoxFor(model => index, new { @class = "span11" })
</div>

改为:

<div class="controls" style="width:20%">
@{ int index = @Model.chapter_index + 1;}
@Html.TextBoxFor(model => index, new { @class = "span11" })
</div>

使用asp.net MVC的 HtmlHelper 时遇到的小问题,报错:Templates can be used only with field access, property access, single-dimension array index, or single-parameter custom indexer expressions.的更多相关文章

  1. ASP.NET MVC 3 入门级常用设置、技巧和报错

    1.ASP.NET MVC 3 如何去除默认验证 这个默认验证是在web.config配置文件中设置的    <add key="ClientValidationEnabled&quo ...

  2. ASP.NET MVC 返回JsonResult序列化内容超出最大限制报错的解决办法

    在使用MVC的时候我们经常会在Controller的Action方法中返回JsonResult对象,但是有时候你如果序列化的对象太大会导致JsonResult从Controller的Action返回后 ...

  3. ASP.NET安全[开发ASP.NET MVC应用程序时值得注意的安全问题](转)

    概述 安全在web领域是一个永远都不会过时的话题,今天我们就来看一看一些在开发ASP.NET MVC应用程序时一些值得我们注意的安全问题.本篇主要包括以下几个内容 : 认证 授权 XSS跨站脚本攻击 ...

  4. ASP.NET MVC 复制MVC项目代码到同一个项目的时候报错The request for ‘home’ has found the following matching controll

    ASP.NET MVC 复制MVC项目代码到同一个项目的时候报错The request for ‘home’ has found the following matching controll “/” ...

  5. 彻底解决asp.net mvc5.2.2:vs2013 cshtml视图文件报错(当前上下文中不存在名称“model”,ViewBag,Url)

    最近遇到一个奇葩的问题,在vs2013下cshtml视图文件报错,出现当前上下文中不存在名称“model”,ViewBag,Url等等),在视图中也没有智能提示了,用@model声明视图的model类 ...

  6. dotnetcore ef 调用多个数据库时用户命令执行操作报错

    dotnetcore ef 调用多个数据库时用户命令执行操作报错 1.多个DbContext 时报错: 报错: More than one DbContext was found. Specify w ...

  7. ionic使用iframe时无法显示网页或报错

    ionic使用iframe时无法显示网页或报错 Uncaught DOMException: Blocked a frame with origin 在config.xml中添加 <access ...

  8. js插件设置innerHTML时,在IE8下报错“未知运行时错误”

    问题描述: 网站中使用了一个js插件,设置innerHTML时,在IE8下报错“未知运行时错误”: <div id=”divContainer”> <a name=”link”> ...

  9. 安装hue时,make apps 编译报错

    安装hue时,make apps 编译报错 :"Error: must have python development packages for 2.6 or 2.7. Could not ...

随机推荐

  1. 【转载】Latex定制章节编号格式和计数器

    原文: http://www.chengkaiblog.com/software-application/latex/customize-section-format-counter.html _1. ...

  2. 论文笔记系列-Multi-Fidelity Automatic Hyper-Parameter Tuning via Transfer Series Expansion

    论文: Multi-Fidelity Automatic Hyper-Parameter Tuning via Transfer Series Expansion 我们都知道实现AutoML的基本思路 ...

  3. C++以const 作为返回值类型的意义

    const rational operator*(const rational& lhs, const rational& rhs); 很多程序员第一眼看到它会纳闷:为什么operat ...

  4. IPC$横向渗透代码实现

    思路 IPC$横向渗透的方法,也是病毒常用的扩散方法. 1.建立连接 2.复制文件到共享中C$.D$.E$.F$ 3.获取服务器的时间 3.设定计划任务按时间执行 用到的Windows API 建立网 ...

  5. hibernate框架学习之数据查询(QBC)helloworld

    package cn.itcast.h3.query.hql; import java.util.List; import org.hibernate.Criteria; import org.hib ...

  6. vue2.x + vux采坑总结(一)

    1.<tab-bar> 切换时,iocn高亮跟着切换问题 vux的Tabbar组件是用来实现底部tab栏,详情见官网文档 , 实现实例截图: 代码如下,控制高亮的是代码凸显部分:selec ...

  7. ansible笔记(3):ansible模块的基本使用

    ansible笔记():ansible模块的基本使用 在前文的基础上,我们已经知道,当我们使用ansible完成实际任务时,需要依靠ansible的各个模块,比如,我们想要去ping某主机,则需要使用 ...

  8. Linux i2c 读写程序

    /* This software uses a BSD license. Copyright (c) 2010, Sean Cross / chumby industriesAll rights re ...

  9. ASP.NET MVC5入门2之Ajax实现数据查询

    开发环境:VS2013 数据库:SQL Server2008R2 架构:ASP.NET MVC5 开发语言:C# 代码下载链接:http://download.csdn.net/detail/u010 ...

  10. POJ 1006 同余方程组

    以前的做法 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring& ...