0
votes

I am recently started learning MVC3. I designed a web application, I am not able to use the form tag by the Razor engine, Have a look at the below code

<html>
<head>
    <title>Index</title>
</head>
<body>
    <div>
    @using (Html.BeginForm("Index","Data", FormMethod.Post))
    {
        <table>                    
        <tr>
            <td>
                @Html.Label("Enter Your Name:")
            </td>
            <td>
                @Html.TextBox("Name")
            </td>
        </tr>
        <tr>
            <td>
                @Html.Label("Enter your Age:")
            </td>
            <td>@Html.TextBox("Age")
            </td>
        </tr>
        <tr>
            <td>
                Select Your Gender:
            </td>
            <td>
                @Html.RadioButton("N_Gender", "M")<span>Male</span>
                @Html.RadioButton("N_Gender", "F")<span>Female</span>
            </td>
        </tr>
        <tr>
            <td>
                <input type="submit" value="Submit" />
            </td>
            <td>
                <button type="reset" value="reset" />
                Reset</button>
            </td>
        </tr>
    </table>
}
</div>

When I run this application I am getting an error like Server Error in '/' Application. Parser Error "Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Encountered end tag "table" with no matching start tag. Are your start/end tags properly balanced?"

2

2 Answers

1
votes

This old but just someone else face this issue. This issue obviously means Razor is having issues resolving closing tab of some element.

The reported line number may be wrong. But there is some error which is making your markup invalid.

One way to resolve (at least this is how I did) is to use some online validation. This will find the tag having the issue!

You can search online or use this one

Hope it helps!

0
votes

Your HTML is badly formatted

try like this

<html>
    <head>
        <title>Index</title>
    </head>
    <body>
        <div>
        @using (Html.BeginForm("Index","Data", FormMethod.Post))
        {
            <table>
                <tr>
                    <td>
                        @Html.Label("Enter Your Name:")
                    </td>
                    <td>
                         @Html.TextBox("Name")
                    </td>
                </tr>
                <tr>
                    <td>                        
                           @Html.Label("Enter Your Age:")
                   </td>
                   <td>
                         @Html.TextBox("N_Age")
                   </td>
                </tr>
                <tr>
                    <td>                        
                            @Html.Label("Enter Your Gender:")
                    </td>
                    <td>
                       @Html.RadioButton("Gender""M")<span>Male</span>
                       @Html.RadioButton("Gender""F")<span>Female</span>
                    </td>
                </tr>
            <tr>
                <td>
                    <input type="submit" value="Submit" />
                </td>
                <td>
                    <button type="reset" value="reset">
                    Reset<button>
                </td>
            </tr>
        </table>
    }

    </div>
</body>
</html>