ASP.NET MVC 2 从不同视图中的部分提交
如果我有一个在多个视图中使用的部分,并提交给它自己的专用操作,那么我如何知道它来自哪个视图,以便我可以返回到该视图?
If I have a partial that is used in multiple views that submits to its own dedicated action, then how do I know which view it has come from so I can go back to that view?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为这里已经回答了: Retrieve the current view name in ASP. NET MVC?
I think it's answered here: Retrieve the current view name in ASP.NET MVC?
只是为了澄清 - “这样你就可以回到那个视图”是什么意思
如果您对每个部分视图使用 ajax 表单,即 Ajax.BeginForm,它们都会自动将自己的 psot 处理到 url(因此是控制器),并且无论是哪个视图,都可以和平地生活在父视图中。
如果发生模型验证,那么您将在这些部分视图中看到它,并且 modelstate 会将发布的值重新填充到模型中,供用户“修复”
Just to clarify - How do you mean 'so you can go back to that view'
If you use ajax forms ie Ajax.BeginForm for each of those partial views, they will all automatically handle their own psots to the url (hence controller) and can live peacefully in the parent view no matter which view it is.
if model validation happens, then you will see it in those partial views and modelstate will repopulate the posted values into the model for the user to 'fix'