当前位置 : 主页 > 网络编程 > ASP >

asp.net – foreach块缺少一个结束“}”字符.确保你有匹配的“}”

来源:互联网 收集:自由互联 发布时间:2021-06-24
我收到错误: The foreach block is missing a closing “}” character. Make sure you have a matching “}” character for all the “{” characters within this block, and that none of the “}” characters are being interpreted as
我收到错误:

The foreach block is missing a closing “}” character. Make sure you have a matching “}” character for all the “{” characters within this block, and that none of the “}” characters are being interpreted as markup.

我的代码是

<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>&nbsp;</td>
                                <td>&nbsp;</td>
                                <td>&nbsp;</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">&nbsp;</td>
                    <td align="right" valign="top"></td>
                </tr>
                <tr>
                    <td align="left">&nbsp;</td>
                    <td align="right" valign="top">&nbsp;</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">&nbsp;</td>
            <td align="right" valign="top">&nbsp;</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">&nbsp;</td>
            <td align="right" valign="top">&nbsp;</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">&nbsp;</td>
            <td align="right" valign="top">&nbsp;</td>
        </tr>
    </table>
</div>

任何人都有任何线索为什么添加此部分会导致此错误?

对于第二个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">
网友评论