Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The foreach block is missing a closing "}" character. Make sure you have a matching "}"

I'm getting error:

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.

My Code is

<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 [email protected] 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>  

Anyone have any clue why adding this section causes this error?

like image 243
sushil Avatar asked Feb 05 '23 10:02

sushil


1 Answers

For the second foreach you shouldn't use a @ sign before it:

    @foreach (var NumberOfRooms in @Model.NumberOfRooms)
    {

        foreach (var RoomDetail in @NumberOfRooms.RoomDetail)
        {

And you have a syntax error at line 57. Instead of

<td style="width:50%; padding-right:5px" " align=" left">

it should be

<td style="width:50%; padding-right:5px" align=" left">
like image 96
Dan Dumitru Avatar answered Mar 02 '23 12:03

Dan Dumitru