2

我正在使用 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> 
4

1 回答 1

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>
于 2013-04-24T07:58:59.220 回答