我不们直接在Foreach 里面直接添加IF,这样会报错,这个前提是子视图,其他的我没有试验过。像这样:

@foreach (Gift.Modules.Model.Entitys.XT_CZ item in ViewData["ZTCZ"] as IList<Gift.Modules.Model.Entitys.XT_CZ>)
{
    string htmlfaction = @item.Action + "()";
    if (true)
    {
         @saveorcancel = true;
    }
    <a href="javascript:void(0)" >
        @item.CZMC
    </a>
}

 应该改成这样:

@foreach (Gift.Modules.Model.Entitys.XT_CZ item in ViewData["ZTCZ"] as IList<Gift.Modules.Model.Entitys.XT_CZ>)
{
    string htmlfaction = @item.Action + "()";
    <text>
    @if (true)
    {
         saveorcancel = true;
    }
    </text>
    <a href="javascript:void(0)" >
        @item.CZMC
    </a>
}

 这样就可以正常运行。

相关文章:

  • 2021-05-22
  • 2022-12-23
  • 2021-07-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-15
猜你喜欢
  • 2021-07-08
  • 2022-01-05
  • 2022-12-23
  • 2022-12-23
  • 2021-09-05
  • 2021-05-19
  • 2021-09-07
相关资源
相似解决方案