共享部分视图 ActionResult 问题
当我从部分视图中调用 ActionResult 时,我试图返回父视图。如果我知道父视图,我可以只输入 return View("Index");,但我不能,因为它们可能是多个父视图,因为此部分视图是共享的......那么我如何返回正确的父视图在操作结果中?
这看起来很简单,但它让我难住了......
更新。这是部分视图:
@model Website.Models.PostModel
@using (Html.BeginForm("SubmitPost", "Home", FormMethod.Post))
{
@Html.TextAreaFor(m => m.Message, 2, 50, null)
<br /><br />
<div class="ui-widget">
Notes: @Html.TextBox("Notes", "", new { @class = "ui-autocomplete-input" })
</div>
<br />
<p>
<input type="submit" value="Post" />
</p>
}
I am trying to return the parent View when I call an ActionResult from within a Partial View. If I know the parent view I can just type in return View("Index");, but I can't because their could be multiple parent views as this partial view is shared... So how do I return the correct parent View in the ActionResult?
This seems so simple, but it has me stumped...
Update. Here is the Partial View:
@model Website.Models.PostModel
@using (Html.BeginForm("SubmitPost", "Home", FormMethod.Post))
{
@Html.TextAreaFor(m => m.Message, 2, 50, null)
<br /><br />
<div class="ui-widget">
Notes: @Html.TextBox("Notes", "", new { @class = "ui-autocomplete-input" })
</div>
<br />
<p>
<input type="submit" value="Post" />
</p>
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您在视图中使用
@{Html.RenderAction("Action");}
进行调用(如果是这样),那么您也可以指定您的routeValues。
在您看来,您将
在控制器中调用 和 :
I assume you're using
@{Html.RenderAction("Action");}
in your view to callif so, then you could specify your routeValues as well.
In your view you would call
and in you controller: