我收到错误:
foreach区块缺少关闭"}"字符。确保你有匹配的"}"所有" {"这个区块内的字符,并没有"}"字符被解释为标记。
我的代码是
<div id="container" style="width:800px; margin:0 auto;">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="middle">
<h1 style="color:#e10b0b; font-size:28px; line-height:30px; margin-bottom:10px;">@Model.HotelName <br /><span style="font-size:18px;">@ViewBag.hotelAddress</span></h1>
<h4 style="margin-top:10px;">Room 1 | 1 Adults | 1 Child | Ages: 1</h4>
</td>
<td align="right" valign="top"><img src=@ViewBag.hotelImage alt=""></td>
</tr>
@*Start Multiple Dynamic Div FOR-FOR-FOR Foreach-Foreach-Foreach not Working both try *@
@foreach (var NumberOfRooms in @Model.NumberOfRooms)
{
@foreach (var RoomDetail in @NumberOfRooms.RoomDetail)
{
<tr>
<td colspan="2" align="left">
<table width="100%" cellpadding="5" cellspacing="0" border="1" bordercolor="#ccc" style="font-size:12px; border-collapse:collapse;">
<tr style="background:#333; color:#fff; font-weight:bold;">
<td>Room Type</td>
<td>Meal Plan</td>
<td>Hotel Name</td>
<td>Availablity</td>
<td>Cost (INR)</td>
</tr>
<tr>
<td>@RoomDetail.RoomType</td>
<td>Breakfast</td>
<td>@Model.HotelName | @RoomDetail.RoomType</td>
<td><span style="background:#379d0f; color:#fff; text-align:center; padding:3px 10px; border-radius:10px;">Available</span></td>
<td>@RoomDetail.RoomMarkupPrice</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td align="right" valign="middle" style="font-size:16px; font-weight:bold;">Total</td>
<td align="left" valign="middle" style="font-size:16px; font-weight:bold;">@RoomDetail.RoomMarkupPrice</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="left"> </td>
<td align="right" valign="top"></td>
</tr>
<tr>
<td align="left"> </td>
<td align="right" valign="top"> </td>
</tr>
<tr>
<td style="width:50%; padding-right:5px" " align=" left">
<p style="font-weight:bold; color:#e10b0b; font-size:12px; margin-bottom:5px;">Cancellation charges</p>
<table width="100%" cellpadding="5" cellspacing="0" border="1" bordercolor="#ccc" style="font-size:12px; border-collapse:collapse;">
<tr style="background:#333; color:#fff; font-weight:bold;">
<td>From date</td>
<td>To date</td>
<td>Cost</td>
</tr>
@foreach (var CancelationDetail in @RoomDetail.CancellationandAmendment)
{
<tr>
<td>@CancelationDetail.Detail[0].FromDate</td>
<td>@CancelationDetail.Detail[0].ToDate</td>
<td>@CancelationDetail.Detail[0].ChargeCost</td>
</tr>
}
</table>
</td>
<td style="width:50%; padding-left:5px" align="left" valign="top">
<p style="font-weight:bold; color:#e10b0b; font-size:12px; margin-bottom:5px;">Amendment charges</p>
<table width="100%" cellpadding="5" cellspacing="0" border="1" bordercolor="#ccc" style="font-size:12px; border-collapse:collapse;">
<tr style="background:#333; color:#fff; font-weight:bold;">
<td>From date</td>
<td>To date</td>
<td>Cost</td>
</tr>
@foreach (var CancelationDetail in @RoomDetail.CancellationandAmendment)
{
<tr>
<td>@CancelationDetail.Detail[1].FromDate</td>
<td>@CancelationDetail.Detail[1].ToDate</td>
<td>@CancelationDetail.Detail[1].ChargeCost</td>
</tr>
}
</table>
</td>
</tr>
}
}
<tr>
<td style="width:50%; padding-right:5px" " align=" left">
<p style="font-weight:bold; color:#e10b0b; font-size:12px; margin-bottom:5px;">Cancellation charges</p>
<table width="100%" cellpadding="5" cellspacing="0" border="1" bordercolor="#ccc" style="font-size:12px; border-collapse:collapse;">
<tr style="background:#333; color:#fff; font-weight:bold;">
<td>From date</td>
<td>To date</td>
<td>Cost</td>
</tr>
@foreach (var CancelationDetail in @RoomDetail.CancellationandAmendment.Detail)
{
<tr>
<td>@CancelationDetail.Detail[0].FromDate</td>
<td>@CancelationDetail.Detail[0].ToDate</td>
<td>@CancelationDetail.Detail[0].ChargeCost</td>
</tr>
}
</table>
</td>
<td style="width:50%; padding-left:5px" align="left" valign="top">
<p style="font-weight:bold; color:#e10b0b; font-size:12px; margin-bottom:5px;">Amendment charges</p>
<table width="100%" cellpadding="5" cellspacing="0" border="1" bordercolor="#ccc" style="font-size:12px; border-collapse:collapse;">
<tr style="background:#333; color:#fff; font-weight:bold;">
<td>From date</td>
<td>To date</td>
<td>Cost</td>
</tr>
@foreach (var CancelationDetail in @RoomDetail.CancellationandAmendment)
{
<tr>
<td>@CancelationDetail.Detail[1].FromDate</td>
<td>@CancelationDetail.Detail[1].ToDate</td>
<td>@CancelationDetail.Detail[1].ChargeCost</td>
</tr>
}
</table>
</td>
</tr>
@*END Multiple Dynamic Div*@
<tr>
<td align="left"> </td>
<td align="right" valign="top"> </td>
</tr>
<tr>
<td colspan="2" align="left">
<h4 style="margin:5px 0;">Tariff Note</h4>
<p style="font-size:12px; line-height:18px; margin:5px 0;">Rate Notes: Hotel Tariff Notes: No show and early departure will be subjected to 100% charge. No date, name and room change allowed. Bookings including children will be based on sharing parents bedding, no separate bed for children is provided unless otherwise stated. Kindly note, any subsequent change in government taxes would be applicable additional and would be paid by the guest directly at the hotel upon check in/out. Bookings including children will be based on sharing parents bedding and no separate bed for children is provided unless otherwise stated.</p>
</td>
</tr>
<tr>
<td align="left"> </td>
<td align="right" valign="top"> </td>
</tr>
<tr>
<td align="left" valign="top" style="border-top:solid 1px #ccc; padding-top:10px;">
<div style="width:60%;">
<h4 style="margin:0; font-size:18px;"> @ViewBag.agencyName</h4>
<p style="margin:3px 0; font-size:14px;">
@ViewBag.agencyAddress
</p>
</div>
</td>
<td align="right" valign="top" style="border-top:solid 1px #ccc; padding-top:10px;">
<img style="width:auto;height:50px;" src=http://agent.antilogvacations.com/Uploads/AgencyLogo/@ViewBag.agencyLogo alt="">
</td>
</tr>
<tr>
<td align="left"> </td>
<td align="right" valign="top"> </td>
</tr>
</table>
</div>
任何人都有任何线索为什么添加此部分会导致此错误?
答案 0 :(得分:7)
对于第二个foreach
,您不应在其前面使用@
符号:
@foreach (var NumberOfRooms in @Model.NumberOfRooms)
{
foreach (var RoomDetail in @NumberOfRooms.RoomDetail)
{
您在第57行遇到语法错误。而不是
<td style="width:50%; padding-right:5px" " align=" left">
应该是
<td style="width:50%; padding-right:5px" align=" left">