asp.net-mvc-4 – MVC 4 Razor如果拆分div标签
发布时间:2020-12-15 20:26:49 所属栏目:asp.Net 来源:网络整理
导读:我有以下MVC 4剃须刀代码: @for (int i = 1; i = 100; i++) { if (currentCol == 1) { Html.Raw("div class=row"); @*Need to do this because can't have a open div within a if compiler doesnt like it *@ } if (currentCol == maxCol) { Html.Raw("/di
我有以下MVC 4剃须刀代码:
@for (int i = 1; i <= 100; i++) { if (currentCol == 1) { Html.Raw("<div class=row>"); @*Need to do this because can't have a open div within a if compiler doesnt like it *@ } if (currentCol == maxCol) { Html.Raw("</div>"); } currentCol++; } 我基本上试图通过if语句的不同路径中的开始和结束标签有条件地生成每个div类行的内容.当我使用直接的HTML,编译器不喜欢它,并认为括号是关闭的.看来Html.Raw是我在线搜索的解决方案,但是当我使用Html.Raw时,当我查看源代码时,div不会显示. 有人知道发生了什么吗? 解决方法
尝试使用@前缀Html.Raw调用:
@for (int i = 1; i <= 100; i++) { if (currentCol == 1) { @Html.Raw("<div class=row>"); } if (currentCol == maxCol) { @Html.Raw("</div>"); } currentCol++; } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – 如何使用npoi将图像放在一个单元格中
- asp.net – 为什么IFormFile显示为null,我该如何解决?
- 使用Visio Viewer载入数据库中的Visio图
- asp.net-mvc – 如何在我自己的自定义助手中使用ASP.NET MV
- asp.net-membership – 如何使用Microsoft.Web.WebPages.OA
- asp.net – 检测处理程序中的身份验证超时并将整个页面重定
- ASP.Net AJAX多页面加载功能可能吗?
- 经典ASP:不支持Server.CreateObject
- query-string – Asp.net 5 mvc 6获取要查看的查询字符串
- asp.net – 处理可变数量的表单字段