我与RenderPage一起Html.BeginForm(不知道我在做什么错了)的问题。ASP.NET MVC3 RenderPage&Html.BeginForm
假设你有一个简单的_Test.cshtml像这样:
@{
<span>Test Text</span>
}
然后假设你有一个简单的页面像这样(至极使用_Test.cshtml):
@{
Layout = null;
var b = new int[] { 0, 1, 2, 3, 4 };
}
@{
<html>
<body>
@* @RenderPage("~/Views/Shared/_Test.cshtml") *@
<div>
@foreach (int i in b)
{
<div>
@using (Html.BeginForm("Action", "Controller", new { id = i }, FormMethod.Post, new { id = "frm_"+ i.ToString() }))
{
<span>Label </span>
<input type="submit" id="@i.ToString()" value="@i.ToString()" />
}
</div>
}
</div>
</body>
</html>
}
如果你对此有何评论在RenderPage助手调用中,您可以正确获得一系列带有相应提交按钮的表单。如果取消注释RenderPage助手,则不会生成标记。不知道发生了什么,有人可以帮我吗?
你为什么要在代码块中包装页面? – SLaks 2011-02-28 15:51:43