使用@ Html.BeginForm()命名mvc3表单时,它在资源管理器中显示System.Web.Mvc.Html.MvcForm {}之间的表单字段

时间:2013-04-24 07:42:46

标签: asp.net-mvc-3

我在ASP.NET MVC3中工作并创建一个表单:

@Html.BeginForm(null, null, FormMethod.Post, new { name = "frmAcnt", id = "frmAcnt" }) 

因为我不想给动作和控制器命名。它工作正常但在Firefox或任何其他浏览器中它显示这两行之间的形式。如何从显示中删除它?

System.Web.Mvc.Html.MvcForm {

}

并在页面源中显示此行

<form action="/Home/AccCode" id="frmAcnt" method="post"     name="frmAcnt">System.Web.Mvc.Html.MvcForm

以下是我的观点

@model CBS.Models.AccntBD

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

<h2>AccCode</h2>

<div>
@Html.BeginForm(null, null, FormMethod.Post, new { name = "frmAcnt", id = "frmAcnt" })
{

<table class="tablestyle">
<tr>
<td>
<input type="text" id="AcCode" name="AcCode" maxlength="10" placeholder="Account Code" autofocus="true" class="required" />

</td>
</tr>

<tr>
<td>
 <label>Description</label>
</td>
<td>
   <input type="text" id ="Descrip" name="Descrip" maxlength="150" placeholder="Desription..." class="Descrip"/>
                     </td>
</tr>

   <tr>
   <td>
   <span>

    <input type="button" name="clear" value="Cancel" onclick="clearForm(this.form);" >
   </span>

          <span>
                    <input type="submit" id="sve" name="action" value="Save" />
        </span>
         <span>
         <input type="button" id="edi" value="Edit" name="action"/>
                     </span>
   <span>
    <input type="button" value="Delete" id="del" name="action"/>     
</span>
</td>
<td>                                     
</td>     
</tr>   
<tr>      
<td>   
</td>
</tr>
</table>     
}
</div> 

1 个答案:

答案 0 :(得分:2)

尝试一次,理想情况下,您可以使用@using (Html.BeginForm()){ }来定义表单

视图

@using (Html.BeginForm(null, null, FormMethod.Post, new { name = "frmAcnt", id = "frmAcnt" }))
{ 
  @* Your Form Content Here *@
}

HTML 输出

<form name="frmAcnt" method="post" id="frmAcnt" action="/"></form>