2013-04-24 44 views
2

我在ASP.NET MVC3工作,并创建一个表单显示System.Web.Mvc.Html.MvcForm {}之间的表单字段:而与@ Html.BeginForm(名称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> 
+0

请发表您该页面视图。 – 2013-04-24 07:45:16

回答

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> 
+0

谢谢satpal它适用于我 – 2013-04-24 08:12:51

+0

发生这种情况是因为您使用'Html.BeginForm'作为独立表达式。它返回一个对象,并将其输出到页面中,该页面调用'obj.ToString()',默认返回类名称。当你使用'using'(你应该),创建的表单对象永远不会被转换为字符串。所以你得到的唯一输出是由窗体的构造函数和析构函数生成的直接响应写入。 – GSerg 2013-04-24 08:23:33

+0

@churahi,如果它的工作和足够好接受它作为回答 – Satpal 2013-04-24 08:24:02