在Asp.net Mvc4中使用If和HtmlBeginform时我的错误在哪里

时间:2013-06-14 19:44:01

标签: html asp.net asp.net-mvc-4

@if (ViewData["Ay"] == "1")
{
    <tr id="Ocak">
        <td><b>Ocak</b></td>
        @using (Html.BeginForm("ButcePlanlama", "Para"))
        {
            <td>@Html.TextBoxFor(s => s.Kira, new { style = "width: 55px; height: 15px;" })</td>
            <td>@Html.TextBoxFor(s => s.Gida, new { style = "width: 55px; height: 15px;" })</td>
            <td><input type="submit" value="Kaydet"></input></td>
        }
        <td>@Html.ActionLink("İstatistik", "İstatistik")</td>
}

因为使用if { }而出错 为什么会出现这个错误?

1 个答案:

答案 0 :(得分:2)

您缺少关闭表格行(</tr>)标记:

@if (ViewData["Ay"] == "1")
{
    <tr id="Ocak">
        <td><b>Ocak</b></td>
        @using (Html.BeginForm("ButcePlanlama", "Para"))
        {
            <td>@Html.TextBoxFor(s => s.Kira, new { style = "width: 55px; height: 15px;" })</td>
            <td>@Html.TextBoxFor(s => s.Gida, new { style = "width: 55px; height: 15px;" })</td>
            <td><input type="submit" value="Kaydet"></input></td>
        }
        <td>@Html.ActionLink("İstatistik", "İstatistik")</td>
    </tr>
}