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


    异常信息: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="20%">
    @{ int index = @Model.chapter_index + 1;}
    @Html.TextBoxFor(model => index, new { @class = "span11" })
    </div>

    改为:

    <div class="controls" style="20%">
    @{ int index = @Model.chapter_index + 1;}
    @Html.TextBoxFor(model => index, new { @class = "span11" })
    </div>
  • 相关阅读:
    Qt Opencv 在Linux下摄像头简单示例(转)
    自制木头台灯
    css3 transition 动画
    css 旋转动画
    maven 搭建 springmvc + jpa +mysql
    搭建前端框架
    mavean
    Mac上安装 Maven
    Mongdb文档学习笔记
    mongoDB高级查询与索引
  • 原文地址:https://www.cnblogs.com/dayang12525/p/10277861.html
Copyright © 2020-2023  润新知