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

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?"

Answers


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>

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!


Need Your Help

MemoryStream mangles my XML? "hexadecimal value 0x0 is illegal in XML documents."

c# .net asp.net-mvc xml stream

I am really a newbie with streams, so I don't really know what I am doing here. :)

Issue with enforcing referential integrity In Access 2013

ms-access relationships table-relationships

So I was mapping out the relationships between tables in a database I'm working on but I ran into some problems.