lundi 10 août 2015

Getting parser error in mvc 5 project when put mvc 4 code snippet

this is my view page for create new product field ,

    @model a.Models.AB_ProductTypeCategoryField

    @{
        ViewBag.Title = "ProductFields_Create";
        Layout = "~/Views/Shared/_Layout.cshtml";
    }

    <h2>ProductFields_Create</h2>


    @using (Html.BeginForm())
    {
        @Html.AntiForgeryToken()
        @Html.ValidationSummary(true)

              <div class="form-horizontal">
                <h4>Create New Product Field</h4>
                  @Html.ValidationSummary(true, "", new { @class = "text-danger" })

                <div class="form-group">
                    @Html.LabelFor(model => model.ProductFieldID, htmlAttributes: new { @class = "control-label col-md-2" })
                    <div class="col-md-10">
                        @Html.EditorFor(model => model.ProductFieldID, new { htmlAttributes = new { @class = "form-control" } })
                        @Html.ValidationMessageFor(model => model.ProductFieldID, "", new { @class = "text-danger" })
                    </div>
                </div>

                <div class="form-group">
                    @Html.LabelFor(model => model.ProductFieldNameEn, htmlAttributes: new { @class = "control-label col-md-2" })
                    <div class="col-md-10">
                        @Html.EditorFor(model => model.ProductFieldNameEn, new { htmlAttributes = new { @class = "form-control" } })
                        @Html.ValidationMessageFor(model => model.ProductFieldNameEn, "", new { @class = "text-danger" })
                    </div>
                </div>



                <div class="form-group">
    <table>
        <tr>
            @{
                int cnt = 0;
                List<albaraka.Models.AB_UserGroup_ProductField> user_group = ViewBag.AB_UserGroup;

                foreach (var user_groups in user_group)
                {
                    if (cnt++ % 3 == 0)
                    {        @:
        </tr>
                    <tr>
                        }


                        @:
                        <td>
                            <input type="checkbox"
                                   name="selectedCourses"
                                   value="@user_groups.UserGroup_ID"
                                   @(Html.Raw(user_groups.IsCheck ? "checked=\"checked\"" : "")) />
                            @user_groups.UserGroup_ID @:  @user_groups.Group_Title
                            @:
                        </td>
                        }
                        @:
                    </tr>
                    }
</table>
</div>




                <div class="form-group">
                    <div class="col-md-offset-2 col-md-10">
                        <input type="submit" value="Create" class="btn btn-default" />
                    </div>
                </div>


            </div>
    }

            <div>
                @Html.ActionLink("Back to List", "Index")
            </div>

            @section Scripts {
                @Scripts.Render("~/bundles/jqueryval")
            }

I've added following code snippet to show check box view like following picture

enter image description here

code snippet that I added to show check-box view

<div class="form-group">
    <table>
        <tr>
            @{
                int cnt = 0;
                List<albaraka.Models.AB_UserGroup_ProductField> user_group = ViewBag.AB_UserGroup;

                foreach (var user_groups in user_group)
                {
                    if (cnt++ % 3 == 0)
                    {        @:
        </tr>
                    <tr>
                        }


                        @:
                        <td>
                            <input type="checkbox"
                                   name="selectedCourses"
                                   value="@user_groups.UserGroup_ID"
                                   @(Html.Raw(user_groups.IsCheck ? "checked=\"checked\"" : "")) />
                            @user_groups.UserGroup_ID @:  @user_groups.Group_Title
                            @:
                        </td>
                        }
                        @:
                    </tr>
                    }
</table>
</div>

Above code snippet extract from mvc 4 project , here that project , but when I put that above code snippet I'm getting following Parser error

The using 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.

I'm not a mature developer with mvc 4 or mvc 5 , really appreciate your help

Aucun commentaire:

Enregistrer un commentaire