@Html.BeginForm 显示“System.Web.Mvc.Html.MvcForm”在页面上
我有一个剃刀视图,我在“if”语句内部添加了一个删除按钮,当该视图在浏览器中呈现时,它接下来显示 “System.Web.Mvc.Html.MvcForm”到删除按钮。
我该如何摆脱它?
代码如下:
<div id="deletestatusupdate">
@if (update.User.UserName.Equals(User.Identity.Name, StringComparison.OrdinalIgnoreCase))
{
@Html.BeginForm("deleteupdate", "home")
@Html.Hidden("returnUrl", Request.Url.ToString())
<button name="id" value="@update.StatusUpdateId">Delete</button>
}
</div>
这是它在渲染的 Razor 视图中的显示方式:
System.Web.Mvc.Html.MvcForm [删除按钮]
假装[删除按钮]是一个实际的按钮,不想截图。
感谢您的帮助。
I have a razor view that I added a delete button to inside of an 'if' statement and when the view is rendered in the browser it is displaying "System.Web.Mvc.Html.MvcForm" next to the delete button.
How do I get rid of it?
Here is the code:
<div id="deletestatusupdate">
@if (update.User.UserName.Equals(User.Identity.Name, StringComparison.OrdinalIgnoreCase))
{
@Html.BeginForm("deleteupdate", "home")
@Html.Hidden("returnUrl", Request.Url.ToString())
<button name="id" value="@update.StatusUpdateId">Delete</button>
}
</div>
Here is how it shows up in the rendered Razor View:
System.Web.Mvc.Html.MvcForm [Delete Button]
pretend that [delete button] is a an actual button, didn't feel like taking a screen shot.
Thank you for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
生成表单的推荐方法如下:
或者您可以这样做:
您原来的方法不起作用的原因是因为
BeginForm()
直接写入输出。The recommended way to generate a form is the following:
Alternatively you could do this:
The reason why your original approach did not work is because
BeginForm()
writes directly to the output.请使用 @using 而不是 using 问题将得到解决 我正在使用 MVC 4
Please use @using instead of using the issue will resolved I am using MVC 4
正确处理我们可以使用它们
Get right for this we can use them