zoukankan      html  css  js  c++  java
  • 使用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>
  • 相关阅读:
    Java字符串(String类)
    Java异常处理
    Scanner使用方法
    OOP之重载
    构造函数和析构函数
    类、对象、方法
    函数
    数组
    ahk之路:利用ahk在window7下实现窗口置顶
    指针的问题
  • 原文地址:https://www.cnblogs.com/dayang12525/p/10277861.html
Copyright © 2011-2022 走看看