将数据发送回 ASP.NET MVC 子操作
既然我们可以由一个主视图+一个局部视图组成一个视图(例如使用RenderAction,指定一个子控制器),那么当主视图渲染输入时,子动作渲染的输入是否可以被定向到子控制器?是否定向到主视图控制器?乍一看,将数据发布到两个操作方法似乎很奇怪,但这与使用部分视图的复合性质完全一致。
这可能或实用吗?
Since we can compose a single view from a main view + a partial view (e.g. using RenderAction, specifying a child controller), is it possible for input rendered by the child action to be directed to the child controller while input rendered by the main view is directed to main view controller? At first, it seems odd to post data to two action methods, but it's consistent with the composite nature of using partial views at all.
Is this possible or practical?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
数据发送到的位置将取决于包含这些输入元素的表单的操作属性。因此,在生成表单时,您可以指定要发布到的控制器和操作:
相同的技术可用于在主视图中呈现的表单,并指定提交时应发布到哪个控制器和操作。
The location to which data is sent will depend on the action attribute of the form that contains those input elements. So when generating the form you could specify a controller and action to post to:
The same technique could be used for forms rendered in the main view and specify to which controller and action they should post when submitted.