简体   繁体   English

是否应在父视图的控制器中编写局部视图的操作方法?

[英]Should I write action methods of the partial view in the controller of the parent view?

After I render a partial view in the view, I wonder what the controller of the partial view is for now? 在视图中渲染局部视图后,我想知道现在局部视图的控制器是什么?
I don't need it anymore? 我不再需要了吗?

Partial Views shouldn't have separate controllers. 部分视图不应具有单独的控制器。 you should place partial view in parents view folder. 您应该将部分视图放在“父视图”文件夹中。

We can decide this on the basis of their functionality. 我们可以根据其功能来决定。 As if your partial view is only meant to be used in your current parent view or it has relevant functionality to the parent view, so in this case we don't need to add a new controller for the partial view. 好像您的部分视图仅打算在当前父视图中使用,或者它具有与父视图相关的功能,因此在这种情况下,我们不需要为部分视图添加新的控制器。 But, if your partial view is going to be used by some other parent views also or it has some common functionality between other controllers also, then we need put this partial in separate controller. 但是,如果您的局部视图也将被其他一些父视图使用,或者它在其他控制器之间也具有某些通用功能,那么我们需要将此局部视图放在单独的控制器中。 @Taichi, this is what i think, decision will be always yours. @Taichi,这就是我的想法,决定永远是你的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否应该测试控制器的Action方法是否正在调用存储库方法并生成正确的视图? - Should I test if my controller's Action method are calling the repository methods and generating the right view? 在渲染局部视图时如何调用控制器操作? - How can I call a controller action when rendering a partial view? 显示部分视图取决于调用的Action和Controller - Show partial view depends on the calling Action and Controller 将viewbag从动作控制器传递到局部视图 - Pass viewbag to partial view from action controller 将数据从局部视图传递到控制器操作 - Pass data from partial view to controller action 当我发送包含具有不同模型的多个部分视图的视图时,控制器应该收到什么? - What the controller should receive when I am sending a view that contains multiple partial view with different models? 如何将部分视图数据传递给父视图控制器 - How to pass partial view data to the parent view controller 调用应在“布局”视图中显示的局部视图的控制器 - Controller that calls a partial view that should display inside the Layout view 我可以使用控制器创建局部视图吗 - Can I Create a Partial View with Controller 从部分视图单击按钮可重定向到父操作方法 - Button click from partial view redirects to Parent action method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM