c# – ASP.NET MVC Razor语法错误
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了c# – ASP.NET MVC Razor语法错误,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1011字,纯文字阅读大概需要2分钟。
内容图文
![c# – ASP.NET MVC Razor语法错误](/upload/InfoBanner/zyjiaocheng/754/d892ef45eeba46498ca778e78c51f651.jpg)
我如何将此代码转换为剃刀语法:
<% for (int i = 0; i < items.Length; i++) %>
<%{
if (i % 3 == 0)
{ %>
<tr>
<% } %>
<td><a href="<%: url[i] %>"><%: title[i] %></a></td>
<% if (i % 3 == 2)
{ %>
</tr>
<% } %>
<%} %>
我试试,但没有成功:
@for (int i = 0; i < items.Length; i++)
{
if (i % 3 == 0)
{
<tr>
}
<td><a href="@(url[i])">@(title[i])</a></td>
if (i % 3 == 2)
{
</tr>
}
}
解决方法:
我找到了解决方案:
@for (int i = 0; i < items.Length; i++)
{
if (i % 3 == 0)
{
@:<tr>
}
<td><a href="@url[i]"><img height="@(48 * Scale.Value)" width="@(48 * Scale.Value)" src="/i@(Scale.Value)/@(items[i]).png"/><span>@text[i]</span></a></td>
if (i % 3 == 2)
{
@:</tr>
}
}
这是introduction to razor syntax,但是:
Use the @: operator or the
<text>
element. The @: outputs a single line
of content containing plain text or
unmatched HTML tags; the
element encloses multiple lines to
output. These options are useful when
you don’t want to render an HTML
element as part of the output.
我不知道,为什么< text>工作中.也许是因为剃刀仍然是RC,而不是释放
内容总结
以上是互联网集市为您收集整理的c# – ASP.NET MVC Razor语法错误全部内容,希望文章能够帮你解决c# – ASP.NET MVC Razor语法错误所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。